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

Side by Side Diff: ios/chrome/browser/ui/toolbar/toolbar_egtest.mm

Issue 2642193012: Make EarlGrey matchers compliant with Chromium style. (Closed)
Patch Set: build.gn and rebase Created 3 years, 11 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <EarlGrey/EarlGrey.h> 5 #import <EarlGrey/EarlGrey.h>
6 #import <XCTest/XCTest.h> 6 #import <XCTest/XCTest.h>
7 7
8 #include "base/ios/ios_util.h" 8 #include "base/ios/ios_util.h"
9 #include "components/strings/grit/components_strings.h" 9 #include "components/strings/grit/components_strings.h"
10 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" 10 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
11 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" 11 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
12 #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h" 12 #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h"
13 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.h" 13 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.h"
14 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" 14 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h"
15 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" 15 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h"
16 #include "ios/chrome/browser/ui/ui_util.h" 16 #include "ios/chrome/browser/ui/ui_util.h"
17 #include "ios/chrome/grit/ios_strings.h" 17 #include "ios/chrome/grit/ios_strings.h"
18 #import "ios/chrome/test/app/chrome_test_util.h" 18 #import "ios/chrome/test/app/chrome_test_util.h"
19 #import "ios/chrome/test/app/tab_test_util.h" 19 #import "ios/chrome/test/app/tab_test_util.h"
20 #import "ios/chrome/test/earl_grey/chrome_assertions.h" 20 #import "ios/chrome/test/earl_grey/chrome_assertions.h"
21 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" 21 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
22 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" 22 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
23 #import "ios/chrome/test/earl_grey/chrome_matchers.h" 23 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
24 #import "ios/chrome/test/earl_grey/chrome_test_case.h" 24 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
25 #import "ios/testing/earl_grey/disabled_test_macros.h" 25 #import "ios/testing/earl_grey/disabled_test_macros.h"
26 #import "ios/web/public/test/http_server.h" 26 #import "ios/web/public/test/http_server.h"
27 #include "ios/web/public/test/http_server_util.h" 27 #include "ios/web/public/test/http_server_util.h"
28 #include "ui/base/l10n/l10n_util_mac.h" 28 #include "ui/base/l10n/l10n_util_mac.h"
29 29
30 using chrome_test_util::buttonWithAccessibilityLabelId; 30 using chrome_test_util::ButtonWithAccessibilityLabelId;
31 using chrome_test_util::omniboxText; 31 using chrome_test_util::OmniboxText;
32 using chrome_test_util::webViewContainingText; 32 using chrome_test_util::WebViewContainingText;
33 33
34 // Toolbar integration tests for Chrome. 34 // Toolbar integration tests for Chrome.
35 @interface ToolbarTestCase : ChromeTestCase 35 @interface ToolbarTestCase : ChromeTestCase
36 @end 36 @end
37 37
38 namespace { 38 namespace {
39 39
40 // Displays the |panel_type| new tab page. On a phone this will send a command 40 // Displays the |panel_type| new tab page. On a phone this will send a command
41 // to display a dialog, on tablet this calls -selectPanel to slide the NTP. 41 // to display a dialog, on tablet this calls -selectPanel to slide the NTP.
42 void SelectNewTabPagePanel(NewTabPage::PanelIdentifier panel_type) { 42 void SelectNewTabPagePanel(NewTabPage::PanelIdentifier panel_type) {
(...skipping 23 matching lines...) Expand all
66 66
67 #pragma mark Tests 67 #pragma mark Tests
68 68
69 // Verifies that entering a URL in the omnibox navigates to the correct URL and 69 // Verifies that entering a URL in the omnibox navigates to the correct URL and
70 // displays content. 70 // displays content.
71 - (void)testEnterURL { 71 - (void)testEnterURL {
72 web::test::SetUpFileBasedHttpServer(); 72 web::test::SetUpFileBasedHttpServer();
73 const GURL URL = web::test::HttpServer::MakeUrl( 73 const GURL URL = web::test::HttpServer::MakeUrl(
74 "http://ios/testing/data/http_server_files/destination.html"); 74 "http://ios/testing/data/http_server_files/destination.html");
75 [ChromeEarlGrey loadURL:URL]; 75 [ChromeEarlGrey loadURL:URL];
76 [[EarlGrey selectElementWithMatcher:omniboxText(URL.GetContent())] 76 [[EarlGrey selectElementWithMatcher:OmniboxText(URL.GetContent())]
77 assertWithMatcher:grey_notNil()]; 77 assertWithMatcher:grey_notNil()];
78 [[EarlGrey selectElementWithMatcher:webViewContainingText("You've arrived")] 78 [[EarlGrey selectElementWithMatcher:WebViewContainingText("You've arrived")]
79 assertWithMatcher:grey_notNil()]; 79 assertWithMatcher:grey_notNil()];
80 } 80 }
81 81
82 // Verifies opening a new tab from the tools menu. 82 // Verifies opening a new tab from the tools menu.
83 - (void)testNewTabFromMenu { 83 - (void)testNewTabFromMenu {
84 chrome_test_util::AssertMainTabCount(1); 84 chrome_test_util::AssertMainTabCount(1);
85 85
86 // Open tab via the UI. 86 // Open tab via the UI.
87 [ChromeEarlGreyUI openToolsMenu]; 87 [ChromeEarlGreyUI openToolsMenu];
88 id<GREYMatcher> newTabButtonMatcher = 88 id<GREYMatcher> newTabButtonMatcher =
(...skipping 24 matching lines...) Expand all
113 - (void)testToolbarOmniboxCancel { 113 - (void)testToolbarOmniboxCancel {
114 // Handset only (tablet does not have cancel button). 114 // Handset only (tablet does not have cancel button).
115 if (IsIPadIdiom()) { 115 if (IsIPadIdiom()) {
116 EARL_GREY_TEST_SKIPPED(@"Test not support on iPad"); 116 EARL_GREY_TEST_SKIPPED(@"Test not support on iPad");
117 } 117 }
118 118
119 const GURL URL = web::test::HttpServer::MakeUrl("http://origin"); 119 const GURL URL = web::test::HttpServer::MakeUrl("http://origin");
120 120
121 [ChromeEarlGrey loadURL:URL]; 121 [ChromeEarlGrey loadURL:URL];
122 122
123 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 123 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
124 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; 124 assertWithMatcher:chrome_test_util::OmniboxText(URL.GetContent())];
125 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 125 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
126 performAction:grey_typeText(@"foo")]; 126 performAction:grey_typeText(@"foo")];
127 127
128 id<GREYMatcher> cancelButton = 128 id<GREYMatcher> cancelButton =
129 grey_allOf(chrome_test_util::cancelButton(), 129 grey_allOf(chrome_test_util::CancelButton(),
130 grey_not(grey_accessibilityID(@"Typing Shield")), nil); 130 grey_not(grey_accessibilityID(@"Typing Shield")), nil);
131 [[EarlGrey selectElementWithMatcher:cancelButton] performAction:grey_tap()]; 131 [[EarlGrey selectElementWithMatcher:cancelButton] performAction:grey_tap()];
132 132
133 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 133 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
134 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; 134 assertWithMatcher:chrome_test_util::OmniboxText(URL.GetContent())];
135 } 135 }
136 136
137 // Tests whether input mode in an omnibox can be canceled via "hide keyboard" 137 // Tests whether input mode in an omnibox can be canceled via "hide keyboard"
138 // button and asserts it doesn't commit the omnibox contents if the input is 138 // button and asserts it doesn't commit the omnibox contents if the input is
139 // canceled. 139 // canceled.
140 - (void)testToolbarOmniboxHideKeyboard { 140 - (void)testToolbarOmniboxHideKeyboard {
141 // TODO(crbug.com/642559): Enable the test for iPad when typing bug is fixed. 141 // TODO(crbug.com/642559): Enable the test for iPad when typing bug is fixed.
142 if (IsIPadIdiom()) { 142 if (IsIPadIdiom()) {
143 EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to a simulator bug."); 143 EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to a simulator bug.");
144 } 144 }
145 145
146 // Tablet only (handset keyboard does not have "hide keyboard" button). 146 // Tablet only (handset keyboard does not have "hide keyboard" button).
147 if (!IsIPadIdiom()) { 147 if (!IsIPadIdiom()) {
148 EARL_GREY_TEST_SKIPPED(@"Test not support on iPhone"); 148 EARL_GREY_TEST_SKIPPED(@"Test not support on iPhone");
149 } 149 }
150 150
151 const GURL URL = web::test::HttpServer::MakeUrl("http://origin"); 151 const GURL URL = web::test::HttpServer::MakeUrl("http://origin");
152 152
153 [ChromeEarlGrey loadURL:URL]; 153 [ChromeEarlGrey loadURL:URL];
154 154
155 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 155 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
156 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; 156 assertWithMatcher:chrome_test_util::OmniboxText(URL.GetContent())];
157 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 157 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
158 performAction:grey_typeText(@"foo")]; 158 performAction:grey_typeText(@"foo")];
159 159
160 id<GREYMatcher> hideKeyboard = grey_accessibilityLabel(@"Hide keyboard"); 160 id<GREYMatcher> hideKeyboard = grey_accessibilityLabel(@"Hide keyboard");
161 [[EarlGrey selectElementWithMatcher:hideKeyboard] performAction:grey_tap()]; 161 [[EarlGrey selectElementWithMatcher:hideKeyboard] performAction:grey_tap()];
162 162
163 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 163 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
164 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; 164 assertWithMatcher:chrome_test_util::OmniboxText(URL.GetContent())];
165 } 165 }
166 166
167 // Tests whether input mode in an omnibox can be canceled via tapping the typing 167 // Tests whether input mode in an omnibox can be canceled via tapping the typing
168 // shield and asserts it doesn't commit the omnibox contents if the input is 168 // shield and asserts it doesn't commit the omnibox contents if the input is
169 // canceled. 169 // canceled.
170 - (void)testToolbarOmniboxTypingShield { 170 - (void)testToolbarOmniboxTypingShield {
171 // Tablet only (handset keyboard does not have "hide keyboard" button). 171 // Tablet only (handset keyboard does not have "hide keyboard" button).
172 if (!IsIPadIdiom()) { 172 if (!IsIPadIdiom()) {
173 EARL_GREY_TEST_SKIPPED(@"Test not support on iPhone"); 173 EARL_GREY_TEST_SKIPPED(@"Test not support on iPhone");
174 } 174 }
175 175
176 const GURL URL = web::test::HttpServer::MakeUrl("http://origin"); 176 const GURL URL = web::test::HttpServer::MakeUrl("http://origin");
177 177
178 [ChromeEarlGrey loadURL:URL]; 178 [ChromeEarlGrey loadURL:URL];
179 179
180 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 180 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
181 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; 181 assertWithMatcher:chrome_test_util::OmniboxText(URL.GetContent())];
182 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 182 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
183 performAction:grey_typeText(@"foo")]; 183 performAction:grey_typeText(@"foo")];
184 184
185 id<GREYMatcher> typingShield = grey_accessibilityID(@"Typing Shield"); 185 id<GREYMatcher> typingShield = grey_accessibilityID(@"Typing Shield");
186 [[EarlGrey selectElementWithMatcher:typingShield] performAction:grey_tap()]; 186 [[EarlGrey selectElementWithMatcher:typingShield] performAction:grey_tap()];
187 187
188 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 188 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
189 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; 189 assertWithMatcher:chrome_test_util::OmniboxText(URL.GetContent())];
190 } 190 }
191 191
192 // Verifies the existence and state of toolbar UI elements. 192 // Verifies the existence and state of toolbar UI elements.
193 - (void)testToolbarUI { 193 - (void)testToolbarUI {
194 id<GREYMatcher> backButton = 194 id<GREYMatcher> backButton =
195 chrome_test_util::buttonWithAccessibilityLabelId(IDS_ACCNAME_BACK); 195 chrome_test_util::ButtonWithAccessibilityLabelId(IDS_ACCNAME_BACK);
196 id<GREYMatcher> forwardButton = 196 id<GREYMatcher> forwardButton =
197 chrome_test_util::buttonWithAccessibilityLabelId(IDS_ACCNAME_FORWARD); 197 chrome_test_util::ButtonWithAccessibilityLabelId(IDS_ACCNAME_FORWARD);
198 id<GREYMatcher> reloadButton = 198 id<GREYMatcher> reloadButton =
199 chrome_test_util::buttonWithAccessibilityLabelId(IDS_IOS_ACCNAME_RELOAD); 199 chrome_test_util::ButtonWithAccessibilityLabelId(IDS_IOS_ACCNAME_RELOAD);
200 id<GREYMatcher> bookmarkButton = 200 id<GREYMatcher> bookmarkButton =
201 chrome_test_util::buttonWithAccessibilityLabelId(IDS_TOOLTIP_STAR); 201 chrome_test_util::ButtonWithAccessibilityLabelId(IDS_TOOLTIP_STAR);
202 id<GREYMatcher> voiceSearchButton = 202 id<GREYMatcher> voiceSearchButton =
203 grey_allOf(chrome_test_util::buttonWithAccessibilityLabelId( 203 grey_allOf(chrome_test_util::ButtonWithAccessibilityLabelId(
204 IDS_IOS_ACCNAME_VOICE_SEARCH), 204 IDS_IOS_ACCNAME_VOICE_SEARCH),
205 grey_ancestor(grey_kindOfClass([ToolbarView class])), nil); 205 grey_ancestor(grey_kindOfClass([ToolbarView class])), nil);
206 NSString* ntpOmniboxLabel = l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT); 206 NSString* ntpOmniboxLabel = l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT);
207 NSString* focusedOmniboxLabel = l10n_util::GetNSString(IDS_ACCNAME_LOCATION); 207 NSString* focusedOmniboxLabel = l10n_util::GetNSString(IDS_ACCNAME_LOCATION);
208 NSString* omniboxLabel = 208 NSString* omniboxLabel =
209 IsIPadIdiom() ? focusedOmniboxLabel : ntpOmniboxLabel; 209 IsIPadIdiom() ? focusedOmniboxLabel : ntpOmniboxLabel;
210 id<GREYMatcher> locationbarButton = 210 id<GREYMatcher> locationbarButton =
211 grey_allOf(grey_accessibilityLabel(omniboxLabel), 211 grey_allOf(grey_accessibilityLabel(omniboxLabel),
212 grey_minimumVisiblePercent(0.2), nil); 212 grey_minimumVisiblePercent(0.2), nil);
213 213
214 [[EarlGrey selectElementWithMatcher:locationbarButton] 214 [[EarlGrey selectElementWithMatcher:locationbarButton]
215 assertWithMatcher:grey_sufficientlyVisible()]; 215 assertWithMatcher:grey_sufficientlyVisible()];
216 216
217 if (IsIPadIdiom()) { 217 if (IsIPadIdiom()) {
218 [[EarlGrey selectElementWithMatcher:backButton] 218 [[EarlGrey selectElementWithMatcher:backButton]
219 assertWithMatcher:grey_sufficientlyVisible()]; 219 assertWithMatcher:grey_sufficientlyVisible()];
220 [[EarlGrey selectElementWithMatcher:forwardButton] 220 [[EarlGrey selectElementWithMatcher:forwardButton]
221 assertWithMatcher:grey_sufficientlyVisible()]; 221 assertWithMatcher:grey_sufficientlyVisible()];
222 [[EarlGrey selectElementWithMatcher:reloadButton] 222 [[EarlGrey selectElementWithMatcher:reloadButton]
223 assertWithMatcher:grey_sufficientlyVisible()]; 223 assertWithMatcher:grey_sufficientlyVisible()];
224 [[EarlGrey selectElementWithMatcher:bookmarkButton] 224 [[EarlGrey selectElementWithMatcher:bookmarkButton]
225 assertWithMatcher:grey_sufficientlyVisible()]; 225 assertWithMatcher:grey_sufficientlyVisible()];
226 [[EarlGrey selectElementWithMatcher:voiceSearchButton] 226 [[EarlGrey selectElementWithMatcher:voiceSearchButton]
227 assertWithMatcher:grey_sufficientlyVisible()]; 227 assertWithMatcher:grey_sufficientlyVisible()];
228 } else { 228 } else {
229 [[EarlGrey selectElementWithMatcher:chrome_test_util::toolsMenuButton()] 229 [[EarlGrey selectElementWithMatcher:chrome_test_util::ToolsMenuButton()]
230 assertWithMatcher:grey_sufficientlyVisible()]; 230 assertWithMatcher:grey_sufficientlyVisible()];
231 [[EarlGrey selectElementWithMatcher:chrome_test_util::showTabsButton()] 231 [[EarlGrey selectElementWithMatcher:chrome_test_util::ShowTabsButton()]
232 assertWithMatcher:grey_sufficientlyVisible()]; 232 assertWithMatcher:grey_sufficientlyVisible()];
233 } 233 }
234 234
235 // Navigate to a page and verify the back button is enabled. 235 // Navigate to a page and verify the back button is enabled.
236 [ChromeEarlGrey loadURL:GURL("chrome://version")]; 236 [ChromeEarlGrey loadURL:GURL("chrome://version")];
237 [[EarlGrey selectElementWithMatcher:backButton] 237 [[EarlGrey selectElementWithMatcher:backButton]
238 assertWithMatcher:grey_interactable()]; 238 assertWithMatcher:grey_interactable()];
239 } 239 }
240 240
241 // Verifies that the keyboard is properly dismissed when a toolbar button 241 // Verifies that the keyboard is properly dismissed when a toolbar button
242 // is pressed (iPad specific). 242 // is pressed (iPad specific).
243 - (void)testIPadKeyboardDismissOnButtonPress { 243 - (void)testIPadKeyboardDismissOnButtonPress {
244 // Tablet only (handset keyboard does not have "hide keyboard" button). 244 // Tablet only (handset keyboard does not have "hide keyboard" button).
245 if (!IsIPadIdiom()) { 245 if (!IsIPadIdiom()) {
246 EARL_GREY_TEST_SKIPPED(@"Test not supported on iPhone"); 246 EARL_GREY_TEST_SKIPPED(@"Test not supported on iPhone");
247 } 247 }
248 248
249 // Load some page so that the "Back" button is tappable. 249 // Load some page so that the "Back" button is tappable.
250 [ChromeEarlGrey loadURL:GURL("chrome://version")]; 250 [ChromeEarlGrey loadURL:GURL("chrome://version")];
251 251
252 // First test: check that the keyboard is opened when tapping the omnibox, 252 // First test: check that the keyboard is opened when tapping the omnibox,
253 // and that it is dismissed when the "Back" button is tapped. 253 // and that it is dismissed when the "Back" button is tapped.
254 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 254 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
255 performAction:grey_tap()]; 255 performAction:grey_tap()];
256 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Typing Shield")] 256 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Typing Shield")]
257 assertWithMatcher:grey_notNil()]; 257 assertWithMatcher:grey_notNil()];
258 258
259 id<GREYMatcher> backButton = 259 id<GREYMatcher> backButton =
260 chrome_test_util::buttonWithAccessibilityLabelId(IDS_ACCNAME_BACK); 260 chrome_test_util::ButtonWithAccessibilityLabelId(IDS_ACCNAME_BACK);
261 [[EarlGrey selectElementWithMatcher:backButton] performAction:grey_tap()]; 261 [[EarlGrey selectElementWithMatcher:backButton] performAction:grey_tap()];
262 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Typing Shield")] 262 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Typing Shield")]
263 assertWithMatcher:grey_notVisible()]; 263 assertWithMatcher:grey_notVisible()];
264 264
265 // Second test: check that the keyboard is opened when tapping the omnibox, 265 // Second test: check that the keyboard is opened when tapping the omnibox,
266 // and that it is dismissed when the tools menu button is tapped. 266 // and that it is dismissed when the tools menu button is tapped.
267 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 267 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
268 performAction:grey_tap()]; 268 performAction:grey_tap()];
269 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Typing Shield")] 269 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Typing Shield")]
270 assertWithMatcher:grey_notNil()]; 270 assertWithMatcher:grey_notNil()];
271 271
272 [[EarlGrey selectElementWithMatcher:chrome_test_util::toolsMenuButton()] 272 [[EarlGrey selectElementWithMatcher:chrome_test_util::ToolsMenuButton()]
273 performAction:grey_tap()]; 273 performAction:grey_tap()];
274 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Typing Shield")] 274 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Typing Shield")]
275 assertWithMatcher:grey_notVisible()]; 275 assertWithMatcher:grey_notVisible()];
276 } 276 }
277 277
278 // Verifies that copying and pasting a URL includes the hidden protocol prefix. 278 // Verifies that copying and pasting a URL includes the hidden protocol prefix.
279 - (void)testCopyPasteURL { 279 - (void)testCopyPasteURL {
280 std::map<GURL, std::string> responses; 280 std::map<GURL, std::string> responses;
281 const GURL URL = web::test::HttpServer::MakeUrl("http://testPage"); 281 const GURL URL = web::test::HttpServer::MakeUrl("http://testPage");
282 const GURL secondURL = web::test::HttpServer::MakeUrl("http://pastePage"); 282 const GURL secondURL = web::test::HttpServer::MakeUrl("http://pastePage");
283 283
284 [ChromeEarlGrey loadURL:URL]; 284 [ChromeEarlGrey loadURL:URL];
285 285
286 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 286 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
287 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; 287 assertWithMatcher:chrome_test_util::OmniboxText(URL.GetContent())];
288 288
289 [ChromeEarlGreyUI openShareMenu]; 289 [ChromeEarlGreyUI openShareMenu];
290 290
291 [[EarlGrey 291 [[EarlGrey
292 selectElementWithMatcher:chrome_test_util::buttonWithAccessibilityLabel( 292 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabel(
293 @"Copy")] performAction:grey_tap()]; 293 @"Copy")] performAction:grey_tap()];
294 294
295 [ChromeEarlGrey loadURL:secondURL]; 295 [ChromeEarlGrey loadURL:secondURL];
296 296
297 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 297 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
298 performAction:grey_longPress()]; 298 performAction:grey_longPress()];
299 299
300 id<GREYMatcher> pasteBarButton = grey_allOf( 300 id<GREYMatcher> pasteBarButton = grey_allOf(
301 grey_accessibilityLabel(@"Paste"), 301 grey_accessibilityLabel(@"Paste"),
302 grey_not(grey_accessibilityTrait(UIAccessibilityTraitButton)), 302 grey_not(grey_accessibilityTrait(UIAccessibilityTraitButton)),
303 grey_not(grey_accessibilityTrait(UIAccessibilityTraitStaticText)), nil); 303 grey_not(grey_accessibilityTrait(UIAccessibilityTraitStaticText)), nil);
304 [[EarlGrey selectElementWithMatcher:pasteBarButton] performAction:grey_tap()]; 304 [[EarlGrey selectElementWithMatcher:pasteBarButton] performAction:grey_tap()];
305 305
306 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 306 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
307 assertWithMatcher:chrome_test_util::omniboxText(URL.spec().c_str())]; 307 assertWithMatcher:chrome_test_util::OmniboxText(URL.spec().c_str())];
308 } 308 }
309 309
310 // Verifies that the clear text button clears any text in the omnibox. 310 // Verifies that the clear text button clears any text in the omnibox.
311 - (void)testOmniboxClearTextButton { 311 - (void)testOmniboxClearTextButton {
312 const GURL URL = web::test::HttpServer::MakeUrl("http://origin"); 312 const GURL URL = web::test::HttpServer::MakeUrl("http://origin");
313 313
314 [ChromeEarlGrey loadURL:URL]; 314 [ChromeEarlGrey loadURL:URL];
315 315
316 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 316 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
317 performAction:grey_typeText(@"foo")]; 317 performAction:grey_typeText(@"foo")];
318 318
319 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 319 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
320 assertWithMatcher:chrome_test_util::omniboxText("foo")]; 320 assertWithMatcher:chrome_test_util::OmniboxText("foo")];
321 321
322 id<GREYMatcher> CancelButton = grey_accessibilityLabel(@"Clear Text"); 322 id<GREYMatcher> CancelButton = grey_accessibilityLabel(@"Clear Text");
323 [[EarlGrey selectElementWithMatcher:CancelButton] performAction:grey_tap()]; 323 [[EarlGrey selectElementWithMatcher:CancelButton] performAction:grey_tap()];
324 324
325 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 325 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
326 assertWithMatcher:chrome_test_util::omniboxText("")]; 326 assertWithMatcher:chrome_test_util::OmniboxText("")];
327 } 327 }
328 328
329 // Types JavaScript into Omnibox and verify that an alert is displayed. 329 // Types JavaScript into Omnibox and verify that an alert is displayed.
330 - (void)testTypeJavaScriptIntoOmnibox { 330 - (void)testTypeJavaScriptIntoOmnibox {
331 // TODO(crbug.com/642544): Enable the test for iPad when typing bug is fixed. 331 // TODO(crbug.com/642544): Enable the test for iPad when typing bug is fixed.
332 if (IsIPadIdiom() && base::ios::IsRunningOnIOS10OrLater()) { 332 if (IsIPadIdiom() && base::ios::IsRunningOnIOS10OrLater()) {
333 EARL_GREY_TEST_DISABLED(@"Disabled for iOS10 iPad due to a typing bug."); 333 EARL_GREY_TEST_DISABLED(@"Disabled for iOS10 iPad due to a typing bug.");
334 } 334 }
335 [ChromeEarlGrey loadURL:GURL("chrome://version")]; 335 [ChromeEarlGrey loadURL:GURL("chrome://version")];
336 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 336 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
337 performAction:grey_typeText(@"javascript:alert('Hello');")]; 337 performAction:grey_typeText(@"javascript:alert('Hello');")];
338 338
339 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Go")] 339 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Go")]
340 performAction:grey_tap()]; 340 performAction:grey_tap()];
341 341
342 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Hello")] 342 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Hello")]
343 assertWithMatcher:grey_notNil()]; 343 assertWithMatcher:grey_notNil()];
344 } 344 }
345 345
346 // Tests typing in the omnibox. 346 // Tests typing in the omnibox.
347 - (void)testToolbarOmniboxTyping { 347 - (void)testToolbarOmniboxTyping {
348 SelectNewTabPagePanel(NewTabPage::kMostVisitedPanel); 348 SelectNewTabPagePanel(NewTabPage::kMostVisitedPanel);
349 349
350 id<GREYMatcher> locationbarButton = grey_allOf( 350 id<GREYMatcher> locationbarButton = grey_allOf(
351 grey_accessibilityLabel(l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT)), 351 grey_accessibilityLabel(l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT)),
352 grey_minimumVisiblePercent(0.2), nil); 352 grey_minimumVisiblePercent(0.2), nil);
353 [[EarlGrey selectElementWithMatcher:locationbarButton] 353 [[EarlGrey selectElementWithMatcher:locationbarButton]
354 assertWithMatcher:grey_text(@"Search or type URL")]; 354 assertWithMatcher:grey_text(@"Search or type URL")];
355 355
356 [[EarlGrey selectElementWithMatcher:locationbarButton] 356 [[EarlGrey selectElementWithMatcher:locationbarButton]
357 performAction:grey_typeText(@"a")]; 357 performAction:grey_typeText(@"a")];
358 [[EarlGrey 358 [[EarlGrey
359 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"a"), 359 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"a"),
360 grey_kindOfClass( 360 grey_kindOfClass(
361 [OmniboxPopupMaterialRow class]), 361 [OmniboxPopupMaterialRow class]),
362 nil)] 362 nil)]
363 assertWithMatcher:grey_sufficientlyVisible()]; 363 assertWithMatcher:grey_sufficientlyVisible()];
364 364
365 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 365 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
366 performAction:grey_typeText(@"b")]; 366 performAction:grey_typeText(@"b")];
367 [[EarlGrey 367 [[EarlGrey
368 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"ab"), 368 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"ab"),
369 grey_kindOfClass( 369 grey_kindOfClass(
370 [OmniboxPopupMaterialRow class]), 370 [OmniboxPopupMaterialRow class]),
371 nil)] 371 nil)]
372 assertWithMatcher:grey_sufficientlyVisible()]; 372 assertWithMatcher:grey_sufficientlyVisible()];
373 373
374 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 374 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
375 performAction:grey_typeText(@"C")]; 375 performAction:grey_typeText(@"C")];
376 [[EarlGrey 376 [[EarlGrey
377 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC"), 377 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC"),
378 grey_kindOfClass( 378 grey_kindOfClass(
379 [OmniboxPopupMaterialRow class]), 379 [OmniboxPopupMaterialRow class]),
380 nil)] 380 nil)]
381 assertWithMatcher:grey_sufficientlyVisible()]; 381 assertWithMatcher:grey_sufficientlyVisible()];
382 382
383 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 383 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
384 performAction:grey_typeText(@"1")]; 384 performAction:grey_typeText(@"1")];
385 [[EarlGrey 385 [[EarlGrey
386 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC1"), 386 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC1"),
387 grey_kindOfClass( 387 grey_kindOfClass(
388 [OmniboxPopupMaterialRow class]), 388 [OmniboxPopupMaterialRow class]),
389 nil)] 389 nil)]
390 assertWithMatcher:grey_sufficientlyVisible()]; 390 assertWithMatcher:grey_sufficientlyVisible()];
391 391
392 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 392 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
393 performAction:grey_typeText(@"2")]; 393 performAction:grey_typeText(@"2")];
394 [[EarlGrey 394 [[EarlGrey
395 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC12"), 395 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC12"),
396 grey_kindOfClass( 396 grey_kindOfClass(
397 [OmniboxPopupMaterialRow class]), 397 [OmniboxPopupMaterialRow class]),
398 nil)] 398 nil)]
399 assertWithMatcher:grey_sufficientlyVisible()]; 399 assertWithMatcher:grey_sufficientlyVisible()];
400 400
401 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 401 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
402 performAction:grey_typeText(@"@")]; 402 performAction:grey_typeText(@"@")];
403 [[EarlGrey 403 [[EarlGrey
404 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC12@"), 404 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC12@"),
405 grey_kindOfClass( 405 grey_kindOfClass(
406 [OmniboxPopupMaterialRow class]), 406 [OmniboxPopupMaterialRow class]),
407 nil)] 407 nil)]
408 assertWithMatcher:grey_sufficientlyVisible()]; 408 assertWithMatcher:grey_sufficientlyVisible()];
409 409
410 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 410 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
411 performAction:grey_typeText(@"{")]; 411 performAction:grey_typeText(@"{")];
412 [[EarlGrey 412 [[EarlGrey
413 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC12@{"), 413 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC12@{"),
414 grey_kindOfClass( 414 grey_kindOfClass(
415 [OmniboxPopupMaterialRow class]), 415 [OmniboxPopupMaterialRow class]),
416 nil)] 416 nil)]
417 assertWithMatcher:grey_sufficientlyVisible()]; 417 assertWithMatcher:grey_sufficientlyVisible()];
418 418
419 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 419 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
420 performAction:grey_typeText(@"#")]; 420 performAction:grey_typeText(@"#")];
421 [[EarlGrey 421 [[EarlGrey
422 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC12@{#"), 422 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC12@{#"),
423 grey_kindOfClass( 423 grey_kindOfClass(
424 [OmniboxPopupMaterialRow class]), 424 [OmniboxPopupMaterialRow class]),
425 nil)] 425 nil)]
426 assertWithMatcher:grey_sufficientlyVisible()]; 426 assertWithMatcher:grey_sufficientlyVisible()];
427 427
428 // TODO(crbug.com/642559): Enable these steps for iPad when typing bug 428 // TODO(crbug.com/642559): Enable these steps for iPad when typing bug
429 // is fixed. 429 // is fixed.
430 if (IsIPadIdiom()) { 430 if (IsIPadIdiom()) {
431 EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to a simulator bug."); 431 EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to a simulator bug.");
432 } else { 432 } else {
433 NSString* cancelButton = l10n_util::GetNSString(IDS_CANCEL); 433 NSString* cancelButton = l10n_util::GetNSString(IDS_CANCEL);
434 NSString* typingShield = @"Hide keyboard"; 434 NSString* typingShield = @"Hide keyboard";
435 NSString* clearText = IsIPadIdiom() ? typingShield : cancelButton; 435 NSString* clearText = IsIPadIdiom() ? typingShield : cancelButton;
436 436
437 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(clearText)] 437 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(clearText)]
438 performAction:grey_tap()]; 438 performAction:grey_tap()];
439 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 439 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
440 assertWithMatcher:chrome_test_util::omniboxText("")]; 440 assertWithMatcher:chrome_test_util::OmniboxText("")];
441 441
442 SelectNewTabPagePanel(NewTabPage::kMostVisitedPanel); 442 SelectNewTabPagePanel(NewTabPage::kMostVisitedPanel);
443 } 443 }
444 } 444 }
445 @end 445 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698