Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: ios/showcase/toolbar/sc_toolbar_egtest.mm

Issue 2936773003: [ios clean] Toolbar accessibility and showcase egtests (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import <EarlGrey/EarlGrey.h>
6
7 #include "components/strings/grit/components_strings.h"
8 #import "ios/chrome/browser/ui/uikit_ui_util.h"
9 #include "ios/chrome/grit/ios_strings.h"
10 #import "ios/chrome/test/earl_grey/accessibility_util.h"
11 #import "ios/showcase/test/showcase_eg_utils.h"
12 #import "ios/showcase/test/showcase_test_case.h"
13 #include "ui/base/l10n/l10n_util.h"
14
15 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support."
17 #endif
18
19 namespace {
20 using ::showcase_utils::Open;
21 using ::showcase_utils::Close;
22 }
23
24 // Tests for the toolbar view controller.
25 @interface SCToolbarTestCase : ShowcaseTestCase
26 @end
27
28 @implementation SCToolbarTestCase
29
30 - (void)setUp {
31 [super setUp];
32 Open(@"ToolbarViewController");
33 }
34
35 - (void)tearDown {
36 Close();
37 if ([UIDevice currentDevice].orientation != UIDeviceOrientationPortrait) {
38 [EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortrait
39 errorOrNil:nil];
40 }
41 [super tearDown];
42 }
43
44 // Test if the Toolbar buttons have the right accessibility labels and commands.
lpromero 2017/06/20 08:38:53 Nit: s/Test/Tests here and below.
sczs 2017/06/21 01:47:56 Done.
45 - (void)testVerifyToolbarButtonsLabelAndAction {
46 // Buttons displayed in both Regular and Compact SizeClasses.
47 // Back Button.
48 [[EarlGrey
49 selectElementWithMatcher:grey_accessibilityLabel(
50 l10n_util::GetNSString(IDS_ACCNAME_BACK))]
51 performAction:grey_tap()];
52 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"goBack")]
53 assertWithMatcher:grey_notNil()];
54 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
55 @"protocol_alerter_done")]
56 performAction:grey_tap()];
57
58 // Forward Button.
59 [[EarlGrey
60 selectElementWithMatcher:grey_accessibilityLabel(
61 l10n_util::GetNSString(IDS_ACCNAME_FORWARD))]
62 performAction:grey_tap()];
63 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"goForward")]
64 assertWithMatcher:grey_notNil()];
65 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
66 @"protocol_alerter_done")]
67 performAction:grey_tap()];
68
69 // ShowTabStrip Button.
70 [[EarlGrey
71 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
72 IDS_IOS_TOOLBAR_SHOW_TABS))]
73 performAction:grey_tap()];
74 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"showTabStrip")]
75 assertWithMatcher:grey_notNil()];
76 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
77 @"protocol_alerter_done")]
78 performAction:grey_tap()];
79
80 // Menu Button.
81 [[EarlGrey
82 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
83 IDS_IOS_TOOLBAR_SETTINGS))]
84 performAction:grey_tap()];
85 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"showToolsMenu")]
86 assertWithMatcher:grey_notNil()];
87 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
88 @"protocol_alerter_done")]
89 performAction:grey_tap()];
90
91 // Buttons displayed only in Regular SizeClass.
92 if (!IsCompact()) {
93 // Share Button.
94 [[EarlGrey
95 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
96 IDS_IOS_TOOLS_MENU_SHARE))]
97 assertWithMatcher:grey_notNil()];
98
99 // Reload Button.
100 [[EarlGrey
101 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
102 IDS_IOS_ACCNAME_RELOAD))]
103 performAction:grey_tap()];
104 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"reloadPage")]
105 assertWithMatcher:grey_notNil()];
106 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
107 @"protocol_alerter_done")]
108 performAction:grey_tap()];
109
110 // Stop Button.
111 [[EarlGrey
112 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
113 IDS_IOS_ACCNAME_STOP))]
114 performAction:grey_tap()];
115 [[EarlGrey
116 selectElementWithMatcher:grey_accessibilityLabel(@"stopLoadingPage")]
117 assertWithMatcher:grey_notNil()];
118 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
119 @"protocol_alerter_done")]
120 performAction:grey_tap()];
121 }
122 }
123
124 // Test that the Menu will be closed on rotation from portrait to landscape and
125 // viceversa.
126 - (void)testRotation {
127 // TODO(crbug.com/652464): Enable the test for iPad when rotation bug is
128 // fixed.
129 if (IsIPadIdiom()) {
130 EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to device rotation bug.");
131 }
132
133 // Rotate from portrait to landscape.
134 if ([EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeRight
135 errorOrNil:nil]) {
136 [[EarlGrey
137 selectElementWithMatcher:grey_accessibilityLabel(@"closeToolsMenu")]
138 assertWithMatcher:grey_notNil()];
139 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
140 @"protocol_alerter_done")]
141 performAction:grey_tap()];
142
143 // If successful rotate back from landscape to portrait.
144 if ([EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortrait
145 errorOrNil:nil]) {
146 [[EarlGrey
147 selectElementWithMatcher:grey_accessibilityLabel(@"closeToolsMenu")]
148 assertWithMatcher:grey_notNil()];
149 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
150 @"protocol_alerter_done")]
151 performAction:grey_tap()];
152 }
153 }
154 }
155
156 // Test that the Regular SizeClass buttons appear when a rotation causes a
157 // SizeClass change from Compact to Regular. E.g. iPhone Plus rotation from
158 // portrait to landscape and viceversa.
159 - (void)testRotationSizeClassChange {
160 // TODO(crbug.com/652464): Enable the test for iPad when rotation bug is
161 // fixed.
162 if (IsIPadIdiom()) {
163 EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to device rotation bug.");
164 }
165
166 // If currently on compact rotate to check if SizeClass changes to regular.
167 if (IsCompact()) {
168 if ([EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeRight
169 errorOrNil:nil]) {
170 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
171 @"protocol_alerter_done")]
172 performAction:grey_tap()];
173 // If SizeClass is not compact after rotation, confirm that some
174 // ToolbarButtons are now visible.
175 if (!IsCompact()) {
176 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
177 l10n_util::GetNSString(
178 IDS_IOS_TOOLS_MENU_SHARE))]
179 assertWithMatcher:grey_notNil()];
180 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
181 l10n_util::GetNSString(
182 IDS_IOS_ACCNAME_RELOAD))]
183 assertWithMatcher:grey_notNil()];
184 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
185 l10n_util::GetNSString(
186 IDS_IOS_ACCNAME_STOP))]
187 assertWithMatcher:grey_notNil()];
188 // Going back to Compact Width.
189 if ([EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortrait
190 errorOrNil:nil]) {
191 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
192 @"protocol_alerter_done")]
193 performAction:grey_tap()];
194 [[EarlGrey
195 selectElementWithMatcher:grey_accessibilityLabel(
196 l10n_util::GetNSString(
197 IDS_IOS_TOOLS_MENU_SHARE))]
198 assertWithMatcher:grey_nil()];
199 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
200 l10n_util::GetNSString(
201 IDS_IOS_ACCNAME_RELOAD))]
202 assertWithMatcher:grey_nil()];
203 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
204 l10n_util::GetNSString(
205 IDS_IOS_ACCNAME_STOP))]
206 assertWithMatcher:grey_nil()];
207 }
208 }
209 }
210 }
211 }
212
213 @end
OLDNEW
« ios/chrome/app/strings/ios_strings.grd ('K') | « ios/showcase/toolbar/sc_toolbar_coordinator.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698