blob: 5b31732d7720a90c8198194e367cc59d150d6362 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*
* Copyright (c) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.devtools.systemimage.uitest.smoke.api31;
import android.app.Instrumentation;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiSelector;
import com.android.devtools.systemimage.uitest.annotations.TestInfo;
import com.android.devtools.systemimage.uitest.common.Res;
import com.android.devtools.systemimage.uitest.framework.SystemImageTestFramework;
import com.android.devtools.systemimage.uitest.utils.AppLauncher;
import com.android.devtools.systemimage.uitest.utils.Wait;
import com.android.devtools.systemimage.uitest.watchers.watcher;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertTrue;
/**
* Test for adding a Google account.
*/
@RunWith(AndroidJUnit4.class)
public class AddGoogleAccountTest {
@Rule
public final SystemImageTestFramework testFramework = new SystemImageTestFramework();
@Rule
public Timeout globalTimeout = Timeout.seconds(120);
/**
* Verifies able to add a Google account using Contacts app.
* <p>
* This is run to qualify releases. Please involve the test team in substantial changes.
* <p>
* TR ID: C14581151
* <p>
* <pre>
* Test Steps:
* 1. Start the emulator.
* 2. Open Contacts app.
* 3. Tap on "Add Account"
* Verify:
* User is prompted to sign in to a Google Account.
* </pre>
*/
@Test
@TestInfo(id = "14581151")
@Ignore("Covered by FAT")
public void testAddAccountUsingContactsApp() throws Exception {
final Instrumentation instrumentation = testFramework.getInstrumentation();
final UiDevice mDevice = testFramework.getDevice();
AppLauncher.launch(instrumentation, "Contacts");
// Check if the app is running for the first time.
UiObject checkingInfo =
mDevice.findObject(new UiSelector().textContains("Checking Info"));
if (checkingInfo.exists()) {
mDevice.pressBack();
}
AppLauncher.launch(instrumentation, "Contacts");
UiObject addAccount = mDevice.findObject(
new UiSelector().textMatches(("(?i)add account(?-i)")));
boolean isFound = addAccount.waitForExists(5L);
if (isFound) {
addAccount.clickAndWaitForNewWindow();
}
UiObject signInHeader = mDevice.findObject(
new UiSelector().textMatches(("(?i)sign in(?-i)")).resourceId("headingText"));
boolean isSignInPage = new Wait(10000L).until(signInHeader::exists);
if (!isSignInPage) {
new watcher(mDevice, Res.ADD_GOOGLE_ACC_WATCHER_PATTERN).checkForCondition();
}
assertTrue("Add Google account page not found",
new Wait(10000L).until(signInHeader::exists));
}
}
|