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

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

Issue 2936773003: [ios clean] Toolbar accessibility and showcase egtests (Closed)
Patch Set: Rename A11y string 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
« no previous file with comments | « ios/showcase/toolbar/sc_toolbar_coordinator.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Tests if the Toolbar buttons have the right accessibility labels and
45 // commands.
46 - (void)testVerifyToolbarButtonsLabelAndAction {
47 // Buttons displayed in both Regular and Compact SizeClasses.
48 // Back Button.
49 [[EarlGrey
50 selectElementWithMatcher:grey_accessibilityLabel(
51 l10n_util::GetNSString(IDS_ACCNAME_BACK))]
52 performAction:grey_tap()];
53 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"goBack")]
54 assertWithMatcher:grey_notNil()];
55 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
56 @"protocol_alerter_done")]
57 performAction:grey_tap()];
58
59 // Forward Button.
60 [[EarlGrey
61 selectElementWithMatcher:grey_accessibilityLabel(
62 l10n_util::GetNSString(IDS_ACCNAME_FORWARD))]
63 performAction:grey_tap()];
64 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"goForward")]
65 assertWithMatcher:grey_notNil()];
66 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
67 @"protocol_alerter_done")]
68 performAction:grey_tap()];
69
70 // ShowTabStrip Button.
71 [[EarlGrey
72 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
73 IDS_IOS_TOOLBAR_SHOW_TABS))]
74 performAction:grey_tap()];
75 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"showTabStrip")]
76 assertWithMatcher:grey_notNil()];
77 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
78 @"protocol_alerter_done")]
79 performAction:grey_tap()];
80
81 // Menu Button.
82 [[EarlGrey
83 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
84 IDS_IOS_TOOLBAR_SETTINGS))]
85 performAction:grey_tap()];
86 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"showToolsMenu")]
87 assertWithMatcher:grey_notNil()];
88 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
89 @"protocol_alerter_done")]
90 performAction:grey_tap()];
91
92 // Buttons displayed only in Regular SizeClass.
93 if (!IsCompact()) {
94 // Share Button.
95 [[EarlGrey
96 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
97 IDS_IOS_TOOLS_MENU_SHARE))]
98 assertWithMatcher:grey_notNil()];
99
100 // Reload Button.
101 [[EarlGrey
102 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
103 IDS_IOS_ACCNAME_RELOAD))]
104 performAction:grey_tap()];
105 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"reloadPage")]
106 assertWithMatcher:grey_notNil()];
107 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
108 @"protocol_alerter_done")]
109 performAction:grey_tap()];
110
111 // Stop Button.
112 [[EarlGrey
113 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
114 IDS_IOS_ACCNAME_STOP))]
115 performAction:grey_tap()];
116 [[EarlGrey
117 selectElementWithMatcher:grey_accessibilityLabel(@"stopLoadingPage")]
118 assertWithMatcher:grey_notNil()];
119 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
120 @"protocol_alerter_done")]
121 performAction:grey_tap()];
122 }
123 }
124
125 // Tests that the Menu will be closed on rotation from portrait to landscape and
126 // viceversa.
127 - (void)testRotation {
128 // TODO(crbug.com/652464): Enable the test for iPad when rotation bug is
129 // fixed.
130 if (IsIPadIdiom()) {
131 EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to device rotation bug.");
132 }
133
134 // Rotate from portrait to landscape.
135 if ([EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeRight
136 errorOrNil:nil]) {
137 [[EarlGrey
138 selectElementWithMatcher:grey_accessibilityLabel(@"closeToolsMenu")]
139 assertWithMatcher:grey_notNil()];
140 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
141 @"protocol_alerter_done")]
142 performAction:grey_tap()];
143
144 // If successful rotate back from landscape to portrait.
145 if ([EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortrait
146 errorOrNil:nil]) {
147 [[EarlGrey
148 selectElementWithMatcher:grey_accessibilityLabel(@"closeToolsMenu")]
149 assertWithMatcher:grey_notNil()];
150 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
151 @"protocol_alerter_done")]
152 performAction:grey_tap()];
153 }
154 }
155 }
156
157 // Tests that the Regular SizeClass buttons appear when a rotation causes a
158 // SizeClass change from Compact to Regular. E.g. iPhone Plus rotation from
159 // portrait to landscape and viceversa.
160 - (void)testRotationSizeClassChange {
161 // TODO(crbug.com/652464): Enable the test for iPad when rotation bug is
162 // fixed.
163 if (IsIPadIdiom()) {
164 EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to device rotation bug.");
165 }
166
167 // If currently on compact rotate to check if SizeClass changes to regular.
168 if (IsCompact()) {
169 if ([EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeRight
170 errorOrNil:nil]) {
171 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
172 @"protocol_alerter_done")]
173 performAction:grey_tap()];
174 // If SizeClass is not compact after rotation, confirm that some
175 // ToolbarButtons are now visible.
176 if (!IsCompact()) {
177 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
178 l10n_util::GetNSString(
179 IDS_IOS_TOOLS_MENU_SHARE))]
180 assertWithMatcher:grey_notNil()];
181 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
182 l10n_util::GetNSString(
183 IDS_IOS_ACCNAME_RELOAD))]
184 assertWithMatcher:grey_notNil()];
185 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
186 l10n_util::GetNSString(
187 IDS_IOS_ACCNAME_STOP))]
188 assertWithMatcher:grey_notNil()];
189 // Going back to Compact Width.
190 if ([EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortrait
191 errorOrNil:nil]) {
192 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
193 @"protocol_alerter_done")]
194 performAction:grey_tap()];
195 [[EarlGrey
196 selectElementWithMatcher:grey_accessibilityLabel(
197 l10n_util::GetNSString(
198 IDS_IOS_TOOLS_MENU_SHARE))]
199 assertWithMatcher:grey_nil()];
200 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
201 l10n_util::GetNSString(
202 IDS_IOS_ACCNAME_RELOAD))]
203 assertWithMatcher:grey_nil()];
204 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
205 l10n_util::GetNSString(
206 IDS_IOS_ACCNAME_STOP))]
207 assertWithMatcher:grey_nil()];
208 }
209 }
210 }
211 }
212 }
213
214 @end
OLDNEW
« no previous file with comments | « 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