This repository has been archived by the owner on Apr 17, 2021. It is now read-only.
/
SettingsTest.java
87 lines (62 loc) · 3.04 KB
/
SettingsTest.java
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
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.tv.firefox.ui.screenshots;
import android.support.test.InstrumentationRegistry;
import android.support.test.espresso.ViewInteraction;
import android.support.test.rule.ActivityTestRule;
import android.support.test.uiautomator.UiDevice;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.mozilla.tv.firefox.MainActivity;
import org.mozilla.tv.firefox.R;
import org.mozilla.tv.firefox.helpers.MainActivityTestRule;
import tools.fastlane.screengrab.Screengrab;
import tools.fastlane.screengrab.locale.LocaleTestRule;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.RootMatchers.isDialog;
import static android.support.test.espresso.matcher.ViewMatchers.hasFocus;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;
public class SettingsTest extends ScreenshotTest {
private UiDevice mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
@ClassRule
public static final LocaleTestRule localeTestRule = new LocaleTestRule();
@Rule
public ActivityTestRule<MainActivity> mActivityTestRule = new MainActivityTestRule();
@After
public void tearDown() {
mActivityTestRule.getActivity().finishAndRemoveTask();
}
@Test
public void showSettingsViews() {
onView(allOf(withId(R.id.navUrlInput), isDisplayed(), hasFocus()));
// visit settings
onView(allOf(withId(R.id.navButtonSettings), isDisplayed()))
.perform(click());
// current settings list view
onView(allOf(withId(R.id.container_web_render), isDisplayed()));
ViewInteraction clearButton = onView(
allOf(withId(R.id.deleteButton), isDisplayed()));
// capture a screenshot of the default settings list
Screengrab.screenshot("settings");
// capture a screenshot of the clear data dialog
clearButton.perform(click());
onView(allOf(withText(R.string.settings_cookies_dialog_content2), isDisplayed())).inRoot(isDialog());
Screengrab.screenshot("clear-all-data");
mDevice.pressBack();
onView(allOf(withId(R.id.aboutButton), isDisplayed()))
.perform(click());
onView(allOf(withId(R.id.webview), isDisplayed()));
onView(allOf(withId(R.string.your_rights), isDisplayed()));
mDevice.waitForIdle();
Screengrab.screenshot("about-screen");
mDevice.pressBack();
}
}