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

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmarks_egtest.mm

Issue 2642193012: Make EarlGrey matchers compliant with Chromium style. (Closed)
Patch Set: build.gn and rebase Created 3 years, 10 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 #include <vector> 5 #include <vector>
6 6
7 #import <EarlGrey/EarlGrey.h> 7 #import <EarlGrey/EarlGrey.h>
8 #import <UIKit/UIKit.h> 8 #import <UIKit/UIKit.h>
9 #import <XCTest/XCTest.h> 9 #import <XCTest/XCTest.h>
10 10
(...skipping 24 matching lines...) Expand all
35 #import "ios/chrome/test/earl_grey/chrome_test_case.h" 35 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
36 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h" 36 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h"
37 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service. h" 37 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service. h"
38 #import "ios/testing/wait_util.h" 38 #import "ios/testing/wait_util.h"
39 #import "ios/web/public/test/http_server.h" 39 #import "ios/web/public/test/http_server.h"
40 #include "ios/web/public/test/http_server_util.h" 40 #include "ios/web/public/test/http_server_util.h"
41 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
42 #include "ui/base/models/tree_node_iterator.h" 42 #include "ui/base/models/tree_node_iterator.h"
43 #include "url/gurl.h" 43 #include "url/gurl.h"
44 44
45 using chrome_test_util::buttonWithAccessibilityLabel; 45 using chrome_test_util::ButtonWithAccessibilityLabel;
46 using chrome_test_util::buttonWithAccessibilityLabelId; 46 using chrome_test_util::ButtonWithAccessibilityLabelId;
47 47
48 namespace { 48 namespace {
49 // TODO(crbug.com/616929): Move common matchers that are useful across tests 49 // TODO(crbug.com/616929): Move common matchers that are useful across tests
50 // into a shared location. 50 // into a shared location.
51 51
52 // Matcher for bookmarks tool tip star. 52 // Matcher for bookmarks tool tip star.
53 id<GREYMatcher> starButton() { 53 id<GREYMatcher> StarButton() {
54 return buttonWithAccessibilityLabelId(IDS_TOOLTIP_STAR); 54 return ButtonWithAccessibilityLabelId(IDS_TOOLTIP_STAR);
55 } 55 }
56 56
57 // Matcher for the button to add bookmark. 57 // Matcher for the button to add bookmark.
58 id<GREYMatcher> addBookmarkButton() { 58 id<GREYMatcher> AddBookmarkButton() {
59 return buttonWithAccessibilityLabelId(IDS_BOOKMARK_ADD_EDITOR_TITLE); 59 return ButtonWithAccessibilityLabelId(IDS_BOOKMARK_ADD_EDITOR_TITLE);
60 } 60 }
61 61
62 // Matcher for the lit star buttom on iPhone that will open the edit button 62 // Matcher for the lit star buttom on iPhone that will open the edit button
63 // screen. 63 // screen.
64 id<GREYMatcher> litStarButtoniPhone() { 64 id<GREYMatcher> LitStarButtoniPhone() {
65 return buttonWithAccessibilityLabelId(IDS_IOS_TOOLS_MENU_EDIT_BOOKMARK); 65 return ButtonWithAccessibilityLabelId(IDS_IOS_TOOLS_MENU_EDIT_BOOKMARK);
66 } 66 }
67 67
68 // Matcher for the button to edit bookmark. 68 // Matcher for the button to edit bookmark.
69 id<GREYMatcher> editBookmarkButton() { 69 id<GREYMatcher> EditBookmarkButton() {
70 return buttonWithAccessibilityLabelId(IDS_IOS_BOOKMARK_ACTION_EDIT); 70 return ButtonWithAccessibilityLabelId(IDS_IOS_BOOKMARK_ACTION_EDIT);
71 } 71 }
72 72
73 // Matcher for the button to close the tools menu. 73 // Matcher for the button to close the tools menu.
74 id<GREYMatcher> closeToolsMenuButton() { 74 id<GREYMatcher> CloseToolsMenuButton() {
75 NSString* closeMenuButtonText = 75 NSString* closeMenuButtonText =
76 l10n_util::GetNSString(IDS_IOS_TOOLBAR_CLOSE_MENU); 76 l10n_util::GetNSString(IDS_IOS_TOOLBAR_CLOSE_MENU);
77 return grey_allOf(grey_accessibilityID(kToolbarToolsMenuButtonIdentifier), 77 return grey_allOf(grey_accessibilityID(kToolbarToolsMenuButtonIdentifier),
78 grey_accessibilityLabel(closeMenuButtonText), nil); 78 grey_accessibilityLabel(closeMenuButtonText), nil);
79 } 79 }
80 80
81 // Matcher for the Done button on the bookmarks UI. 81 // Matcher for the Done button on the bookmarks UI.
82 id<GREYMatcher> bookmarksDoneButton() { 82 id<GREYMatcher> BookmarksDoneButton() {
83 return grey_allOf( 83 return grey_allOf(
84 buttonWithAccessibilityLabelId(IDS_IOS_BOOKMARK_DONE_BUTTON), 84 ButtonWithAccessibilityLabelId(IDS_IOS_BOOKMARK_DONE_BUTTON),
85 grey_not(grey_accessibilityTrait(UIAccessibilityTraitKeyboardKey)), nil); 85 grey_not(grey_accessibilityTrait(UIAccessibilityTraitKeyboardKey)), nil);
86 } 86 }
87 87
88 // Matcher for the More Menu. 88 // Matcher for the More Menu.
89 id<GREYMatcher> moreMenuButton() { 89 id<GREYMatcher> MoreMenuButton() {
90 return buttonWithAccessibilityLabelId( 90 return ButtonWithAccessibilityLabelId(
91 IDS_IOS_BOOKMARK_NEW_MORE_BUTTON_ACCESSIBILITY_LABEL); 91 IDS_IOS_BOOKMARK_NEW_MORE_BUTTON_ACCESSIBILITY_LABEL);
92 } 92 }
93 93
94 // Types of actions possible in the contextual action sheet. 94 // Types of actions possible in the contextual action sheet.
95 typedef NS_ENUM(NSUInteger, Action) { 95 typedef NS_ENUM(NSUInteger, Action) {
96 ActionSelect, 96 ActionSelect,
97 ActionEdit, 97 ActionEdit,
98 ActionMove, 98 ActionMove,
99 ActionDelete, 99 ActionDelete,
100 }; 100 };
101 101
102 // Matcher for the action sheet's buttons. 102 // Matcher for the action sheet's buttons.
103 id<GREYMatcher> actionSheet(Action action) { 103 id<GREYMatcher> ActionSheet(Action action) {
104 int accessibilityLabelMessageID; 104 int accessibilityLabelMessageID;
105 switch (action) { 105 switch (action) {
106 case ActionSelect: 106 case ActionSelect:
107 accessibilityLabelMessageID = IDS_IOS_BOOKMARK_ACTION_SELECT; 107 accessibilityLabelMessageID = IDS_IOS_BOOKMARK_ACTION_SELECT;
108 break; 108 break;
109 case ActionEdit: 109 case ActionEdit:
110 accessibilityLabelMessageID = IDS_IOS_BOOKMARK_ACTION_EDIT; 110 accessibilityLabelMessageID = IDS_IOS_BOOKMARK_ACTION_EDIT;
111 break; 111 break;
112 case ActionMove: 112 case ActionMove:
113 accessibilityLabelMessageID = IDS_IOS_BOOKMARK_ACTION_MOVE; 113 accessibilityLabelMessageID = IDS_IOS_BOOKMARK_ACTION_MOVE;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 // Verifies that adding a bookmark and removing a bookmark via the UI properly 156 // Verifies that adding a bookmark and removing a bookmark via the UI properly
157 // updates the BookmarkModel. 157 // updates the BookmarkModel.
158 - (void)testAddRemoveBookmark { 158 - (void)testAddRemoveBookmark {
159 const GURL bookmarkedURL = web::test::HttpServer::MakeUrl( 159 const GURL bookmarkedURL = web::test::HttpServer::MakeUrl(
160 "http://ios/testing/data/http_server_files/pony.html"); 160 "http://ios/testing/data/http_server_files/pony.html");
161 std::string expectedURLContent = bookmarkedURL.GetContent(); 161 std::string expectedURLContent = bookmarkedURL.GetContent();
162 NSString* bookmarkTitle = @"my bookmark"; 162 NSString* bookmarkTitle = @"my bookmark";
163 163
164 [ChromeEarlGrey loadURL:bookmarkedURL]; 164 [ChromeEarlGrey loadURL:bookmarkedURL];
165 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( 165 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
166 expectedURLContent)] 166 expectedURLContent)]
167 assertWithMatcher:grey_notNil()]; 167 assertWithMatcher:grey_notNil()];
168 168
169 // Add the bookmark from the UI. 169 // Add the bookmark from the UI.
170 [[self class] bookmarkCurrentTabWithTitle:bookmarkTitle]; 170 [[self class] bookmarkCurrentTabWithTitle:bookmarkTitle];
171 171
172 // Verify the bookmark is set. 172 // Verify the bookmark is set.
173 [[self class] assertBookmarksWithTitle:bookmarkTitle expectedCount:1]; 173 [[self class] assertBookmarksWithTitle:bookmarkTitle expectedCount:1];
174 174
175 NSString* const kStarLitLabel = 175 NSString* const kStarLitLabel =
176 !IsCompact() ? l10n_util::GetNSString(IDS_TOOLTIP_STAR) 176 !IsCompact() ? l10n_util::GetNSString(IDS_TOOLTIP_STAR)
177 : l10n_util::GetNSString(IDS_IOS_BOOKMARK_EDIT_SCREEN_TITLE); 177 : l10n_util::GetNSString(IDS_IOS_BOOKMARK_EDIT_SCREEN_TITLE);
178 // Verify the star is lit. 178 // Verify the star is lit.
179 if (IsCompact()) { 179 if (IsCompact()) {
180 [ChromeEarlGreyUI openToolsMenu]; 180 [ChromeEarlGreyUI openToolsMenu];
181 } 181 }
182 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(kStarLitLabel)] 182 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(kStarLitLabel)]
183 assertWithMatcher:grey_notNil()]; 183 assertWithMatcher:grey_notNil()];
184 184
185 // Clear the bookmark via the UI. 185 // Clear the bookmark via the UI.
186 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(kStarLitLabel)] 186 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(kStarLitLabel)]
187 performAction:grey_tap()]; 187 performAction:grey_tap()];
188 [[EarlGrey selectElementWithMatcher:actionSheet(ActionDelete)] 188 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionDelete)]
189 performAction:grey_tap()]; 189 performAction:grey_tap()];
190 190
191 // Verify the bookmark is not in the BookmarkModel. 191 // Verify the bookmark is not in the BookmarkModel.
192 [[self class] assertBookmarksWithTitle:bookmarkTitle expectedCount:0]; 192 [[self class] assertBookmarksWithTitle:bookmarkTitle expectedCount:0];
193 193
194 NSString* const kStarUnlitLabel = 194 NSString* const kStarUnlitLabel =
195 !IsCompact() ? l10n_util::GetNSString(IDS_TOOLTIP_STAR) 195 !IsCompact() ? l10n_util::GetNSString(IDS_TOOLTIP_STAR)
196 : l10n_util::GetNSString(IDS_BOOKMARK_ADD_EDITOR_TITLE); 196 : l10n_util::GetNSString(IDS_BOOKMARK_ADD_EDITOR_TITLE);
197 197
198 // Verify the star is not lit. 198 // Verify the star is not lit.
199 if (IsCompact()) { 199 if (IsCompact()) {
200 [ChromeEarlGreyUI openToolsMenu]; 200 [ChromeEarlGreyUI openToolsMenu];
201 } 201 }
202 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(kStarUnlitLabel)] 202 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(kStarUnlitLabel)]
203 assertWithMatcher:grey_notNil()]; 203 assertWithMatcher:grey_notNil()];
204 204
205 // TODO(crbug.com/617652): This code should be removed when a common helper 205 // TODO(crbug.com/617652): This code should be removed when a common helper
206 // is added to close any menus, which should be run as test setup. 206 // is added to close any menus, which should be run as test setup.
207 if (IsCompact()) { 207 if (IsCompact()) {
208 [[EarlGrey selectElementWithMatcher:closeToolsMenuButton()] 208 [[EarlGrey selectElementWithMatcher:CloseToolsMenuButton()]
209 performAction:grey_tap()]; 209 performAction:grey_tap()];
210 } 210 }
211 211
212 // Close the opened tab. 212 // Close the opened tab.
213 base::scoped_nsobject<GenericChromeCommand> command( 213 base::scoped_nsobject<GenericChromeCommand> command(
214 [[GenericChromeCommand alloc] initWithTag:IDC_CLOSE_TAB]); 214 [[GenericChromeCommand alloc] initWithTag:IDC_CLOSE_TAB]);
215 chrome_test_util::RunCommandWithActiveViewController(command); 215 chrome_test_util::RunCommandWithActiveViewController(command);
216 } 216 }
217 217
218 // Tests that tapping a bookmark on the NTP navigates to the proper URL. 218 // Tests that tapping a bookmark on the NTP navigates to the proper URL.
219 - (void)testTapBookmark { 219 - (void)testTapBookmark {
220 const GURL bookmarkURL = web::test::HttpServer::MakeUrl( 220 const GURL bookmarkURL = web::test::HttpServer::MakeUrl(
221 "http://ios/testing/data/http_server_files/destination.html"); 221 "http://ios/testing/data/http_server_files/destination.html");
222 NSString* bookmarkTitle = @"smokeTapBookmark"; 222 NSString* bookmarkTitle = @"smokeTapBookmark";
223 223
224 // Load a bookmark into the bookmark model. 224 // Load a bookmark into the bookmark model.
225 [[self class] addBookmark:bookmarkURL withTitle:bookmarkTitle]; 225 [[self class] addBookmark:bookmarkURL withTitle:bookmarkTitle];
226 226
227 // Open the UI for Bookmarks. 227 // Open the UI for Bookmarks.
228 [[self class] openMobileBookmarks]; 228 [[self class] openMobileBookmarks];
229 229
230 // Verify bookmark is visible. 230 // Verify bookmark is visible.
231 [[EarlGrey 231 [[EarlGrey
232 selectElementWithMatcher:buttonWithAccessibilityLabel(bookmarkTitle)] 232 selectElementWithMatcher:ButtonWithAccessibilityLabel(bookmarkTitle)]
233 assertWithMatcher:grey_sufficientlyVisible() 233 assertWithMatcher:grey_sufficientlyVisible()
234 error:nil]; 234 error:nil];
235 235
236 // Tap on the bookmark and verify the URL that appears in the omnibox. 236 // Tap on the bookmark and verify the URL that appears in the omnibox.
237 [[EarlGrey 237 [[EarlGrey
238 selectElementWithMatcher:buttonWithAccessibilityLabel(bookmarkTitle)] 238 selectElementWithMatcher:ButtonWithAccessibilityLabel(bookmarkTitle)]
239 performAction:grey_tap()]; 239 performAction:grey_tap()];
240 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( 240 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
241 bookmarkURL.GetContent())] 241 bookmarkURL.GetContent())]
242 assertWithMatcher:grey_notNil()]; 242 assertWithMatcher:grey_notNil()];
243 } 243 }
244 244
245 // Test to set bookmarks in multiple tabs. 245 // Test to set bookmarks in multiple tabs.
246 - (void)testBookmarkMultipleTabs { 246 - (void)testBookmarkMultipleTabs {
247 const GURL firstURL = web::test::HttpServer::MakeUrl( 247 const GURL firstURL = web::test::HttpServer::MakeUrl(
248 "http://ios/testing/data/http_server_files/pony.html"); 248 "http://ios/testing/data/http_server_files/pony.html");
249 const GURL secondURL = web::test::HttpServer::MakeUrl( 249 const GURL secondURL = web::test::HttpServer::MakeUrl(
250 "http://ios/testing/data/http_server_files/destination.html"); 250 "http://ios/testing/data/http_server_files/destination.html");
(...skipping 13 matching lines...) Expand all
264 // Tap on one of the standard bookmark. Verify that it loads. 264 // Tap on one of the standard bookmark. Verify that it loads.
265 [[EarlGrey selectElementWithMatcher:grey_text(@"Second URL")] 265 [[EarlGrey selectElementWithMatcher:grey_text(@"Second URL")]
266 performAction:grey_tap()]; 266 performAction:grey_tap()];
267 267
268 // Wait for the page to load. 268 // Wait for the page to load.
269 [ChromeEarlGrey waitForPageToFinishLoading]; 269 [ChromeEarlGrey waitForPageToFinishLoading];
270 270
271 // Check the URL is correct. 271 // Check the URL is correct.
272 const GURL secondURL = web::test::HttpServer::MakeUrl( 272 const GURL secondURL = web::test::HttpServer::MakeUrl(
273 "http://ios/testing/data/http_server_files/destination.html"); 273 "http://ios/testing/data/http_server_files/destination.html");
274 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 274 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
275 assertWithMatcher:chrome_test_util::omniboxText(secondURL.GetContent())]; 275 assertWithMatcher:chrome_test_util::OmniboxText(secondURL.GetContent())];
276 } 276 }
277 277
278 // Try deleting a bookmark, then undoing that delete. 278 // Try deleting a bookmark, then undoing that delete.
279 - (void)testUndoDeleteBookmark { 279 - (void)testUndoDeleteBookmark {
280 [[self class] setupStandardBookmarks]; 280 [[self class] setupStandardBookmarks];
281 [[self class] openMobileBookmarks]; 281 [[self class] openMobileBookmarks];
282 282
283 // Load the menu for a bookmark. 283 // Load the menu for a bookmark.
284 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL Info")] 284 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL Info")]
285 performAction:grey_tap()]; 285 performAction:grey_tap()];
286 286
287 // Delete it. 287 // Delete it.
288 [[EarlGrey selectElementWithMatcher:actionSheet(ActionDelete)] 288 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionDelete)]
289 performAction:grey_tap()]; 289 performAction:grey_tap()];
290 290
291 // Wait until it's gone. 291 // Wait until it's gone.
292 [[self class] waitForDeletionOfBookmarkWithTitle:@"Second URL"]; 292 [[self class] waitForDeletionOfBookmarkWithTitle:@"Second URL"];
293 293
294 // Press undo 294 // Press undo
295 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Undo")] 295 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Undo")]
296 performAction:grey_tap()]; 296 performAction:grey_tap()];
297 297
298 // Verify it's back. 298 // Verify it's back.
299 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL")] 299 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL")]
300 assertWithMatcher:grey_notNil()]; 300 assertWithMatcher:grey_notNil()];
301 } 301 }
302 302
303 // Try deleting a bookmark from the edit screen, then undoing that delete. 303 // Try deleting a bookmark from the edit screen, then undoing that delete.
304 - (void)testUndoDeleteBookmarkFromEditScreen { 304 - (void)testUndoDeleteBookmarkFromEditScreen {
305 [[self class] setupStandardBookmarks]; 305 [[self class] setupStandardBookmarks];
306 [[self class] openMobileBookmarks]; 306 [[self class] openMobileBookmarks];
307 307
308 // Load the menu for a bookmark. 308 // Load the menu for a bookmark.
309 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL Info")] 309 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL Info")]
310 performAction:grey_tap()]; 310 performAction:grey_tap()];
311 311
312 // Tap the edit action. 312 // Tap the edit action.
313 [[EarlGrey selectElementWithMatcher:actionSheet(ActionEdit)] 313 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
314 performAction:grey_tap()]; 314 performAction:grey_tap()];
315 315
316 // Delete it. 316 // Delete it.
317 [[EarlGrey selectElementWithMatcher:actionSheet(ActionDelete)] 317 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionDelete)]
318 performAction:grey_tap()]; 318 performAction:grey_tap()];
319 319
320 // Wait until it's gone. 320 // Wait until it's gone.
321 ConditionBlock condition = ^{ 321 ConditionBlock condition = ^{
322 NSError* error = nil; 322 NSError* error = nil;
323 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL")] 323 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL")]
324 assertWithMatcher:grey_notVisible() 324 assertWithMatcher:grey_notVisible()
325 error:&error]; 325 error:&error];
326 return error == nil; 326 return error == nil;
327 }; 327 };
(...skipping 15 matching lines...) Expand all
343 [[self class] openMobileBookmarks]; 343 [[self class] openMobileBookmarks];
344 344
345 // Verify that folder 2 only has 1 child. 345 // Verify that folder 2 only has 1 child.
346 [[self class] assertChildCount:1 ofFolderWithName:@"Folder 2"]; 346 [[self class] assertChildCount:1 ofFolderWithName:@"Folder 2"];
347 347
348 // Load the menu for a bookmark. 348 // Load the menu for a bookmark.
349 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL Info")] 349 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL Info")]
350 performAction:grey_tap()]; 350 performAction:grey_tap()];
351 351
352 // Select a first bookmark. 352 // Select a first bookmark.
353 [[EarlGrey selectElementWithMatcher:actionSheet(ActionSelect)] 353 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionSelect)]
354 performAction:grey_tap()]; 354 performAction:grey_tap()];
355 355
356 // Select a second bookmark. 356 // Select a second bookmark.
357 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL")] 357 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL")]
358 performAction:grey_tap()]; 358 performAction:grey_tap()];
359 359
360 // Choose the move action. 360 // Choose the move action.
361 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Move")] 361 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Move")]
362 performAction:grey_tap()]; 362 performAction:grey_tap()];
363 363
(...skipping 28 matching lines...) Expand all
392 392
393 - (void)testLabelUpdatedUponMove { 393 - (void)testLabelUpdatedUponMove {
394 [[self class] setupStandardBookmarks]; 394 [[self class] setupStandardBookmarks];
395 [[self class] openMobileBookmarks]; 395 [[self class] openMobileBookmarks];
396 396
397 // Load the menu for a bookmark. 397 // Load the menu for a bookmark.
398 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 398 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
399 performAction:grey_tap()]; 399 performAction:grey_tap()];
400 400
401 // Tap on the Edit action. 401 // Tap on the Edit action.
402 [[EarlGrey selectElementWithMatcher:actionSheet(ActionEdit)] 402 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
403 performAction:grey_tap()]; 403 performAction:grey_tap()];
404 404
405 // Tap the Folder button. 405 // Tap the Folder button.
406 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")] 406 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")]
407 performAction:grey_tap()]; 407 performAction:grey_tap()];
408 408
409 // Create a new folder with default name. 409 // Create a new folder with default name.
410 [[self class] addFolderWithName:nil]; 410 [[self class] addFolderWithName:nil];
411 411
412 // Verify that the editor is present. 412 // Verify that the editor is present.
413 [[EarlGrey 413 [[EarlGrey
414 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 414 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
415 assertWithMatcher:grey_notNil()]; 415 assertWithMatcher:grey_notNil()];
416 416
417 // Check the new folder label. 417 // Check the new folder label.
418 [[EarlGrey 418 [[EarlGrey
419 selectElementWithMatcher:grey_allOf( 419 selectElementWithMatcher:grey_allOf(
420 grey_accessibilityID(@"Change Folder"), 420 grey_accessibilityID(@"Change Folder"),
421 grey_accessibilityLabel(@"New Folder"), nil)] 421 grey_accessibilityLabel(@"New Folder"), nil)]
422 assertWithMatcher:grey_notNil()]; 422 assertWithMatcher:grey_notNil()];
423 } 423 }
424 424
425 // Test the creation of a bookmark and new folder. 425 // Test the creation of a bookmark and new folder.
426 - (void)testAddBookmarkInNewFolder { 426 - (void)testAddBookmarkInNewFolder {
427 const GURL bookmarkedURL = web::test::HttpServer::MakeUrl( 427 const GURL bookmarkedURL = web::test::HttpServer::MakeUrl(
428 "http://ios/testing/data/http_server_files/pony.html"); 428 "http://ios/testing/data/http_server_files/pony.html");
429 std::string expectedURLContent = bookmarkedURL.GetContent(); 429 std::string expectedURLContent = bookmarkedURL.GetContent();
430 430
431 [ChromeEarlGrey loadURL:bookmarkedURL]; 431 [ChromeEarlGrey loadURL:bookmarkedURL];
432 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( 432 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
433 expectedURLContent)] 433 expectedURLContent)]
434 assertWithMatcher:grey_notNil()]; 434 assertWithMatcher:grey_notNil()];
435 435
436 [[self class] starCurrentTab]; 436 [[self class] starCurrentTab];
437 437
438 // Verify the snackbar title. 438 // Verify the snackbar title.
439 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bookmarked")] 439 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bookmarked")]
440 assertWithMatcher:grey_notNil()]; 440 assertWithMatcher:grey_notNil()];
441 441
442 // Tap on the snackbar. 442 // Tap on the snackbar.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 NSString* newFolderTitle = @"New Folder Title"; 478 NSString* newFolderTitle = @"New Folder Title";
479 479
480 [[self class] setupStandardBookmarks]; 480 [[self class] setupStandardBookmarks];
481 [[self class] openMobileBookmarks]; 481 [[self class] openMobileBookmarks];
482 [[self class] openEditBookmarkFolderWithFolderTitle:existingFolderTitle]; 482 [[self class] openEditBookmarkFolderWithFolderTitle:existingFolderTitle];
483 [[self class] renameBookmarkFolderWithFolderTitle:newFolderTitle]; 483 [[self class] renameBookmarkFolderWithFolderTitle:newFolderTitle];
484 [[self class] closeEditBookmarkFolder]; 484 [[self class] closeEditBookmarkFolder];
485 485
486 if (IsCompact()) { 486 if (IsCompact()) {
487 // Exit from bookmarks modal. IPad shows bookmarks in tab. 487 // Exit from bookmarks modal. IPad shows bookmarks in tab.
488 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 488 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
489 performAction:grey_tap()]; 489 performAction:grey_tap()];
490 } 490 }
491 491
492 // Verify that the change has been made. 492 // Verify that the change has been made.
493 [[self class] openMobileBookmarks]; 493 [[self class] openMobileBookmarks];
494 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(existingFolderTitle)] 494 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(existingFolderTitle)]
495 assertWithMatcher:grey_nil()]; 495 assertWithMatcher:grey_nil()];
496 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(newFolderTitle)] 496 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(newFolderTitle)]
497 assertWithMatcher:grey_notNil()]; 497 assertWithMatcher:grey_notNil()];
498 } 498 }
499 499
500 // Tests that the default folder bookmarks are saved in is updated to the last 500 // Tests that the default folder bookmarks are saved in is updated to the last
501 // used folder. 501 // used folder.
502 - (void)testStickyDefaultFolder { 502 - (void)testStickyDefaultFolder {
503 [[self class] setupStandardBookmarks]; 503 [[self class] setupStandardBookmarks];
504 [[self class] openMobileBookmarks]; 504 [[self class] openMobileBookmarks];
505 505
506 // Tap on the top-right button. 506 // Tap on the top-right button.
507 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 507 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
508 performAction:grey_tap()]; 508 performAction:grey_tap()];
509 509
510 // Tap the edit action. 510 // Tap the edit action.
511 [[EarlGrey selectElementWithMatcher:actionSheet(ActionEdit)] 511 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
512 performAction:grey_tap()]; 512 performAction:grey_tap()];
513 513
514 // Tap the Folder button. 514 // Tap the Folder button.
515 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")] 515 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")]
516 performAction:grey_tap()]; 516 performAction:grey_tap()];
517 517
518 // Create a new folder. 518 // Create a new folder.
519 [[self class] addFolderWithName:@"Sticky Folder"]; 519 [[self class] addFolderWithName:@"Sticky Folder"];
520 520
521 // Verify that the editor is present. 521 // Verify that the editor is present.
522 [[EarlGrey 522 [[EarlGrey
523 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 523 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
524 assertWithMatcher:grey_sufficientlyVisible()]; 524 assertWithMatcher:grey_sufficientlyVisible()];
525 525
526 // Tap the Done button. 526 // Tap the Done button.
527 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 527 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
528 performAction:grey_tap()]; 528 performAction:grey_tap()];
529 [[EarlGrey 529 [[EarlGrey
530 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 530 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
531 assertWithMatcher:grey_notVisible()]; 531 assertWithMatcher:grey_notVisible()];
532 532
533 if (IsCompact()) { 533 if (IsCompact()) {
534 // Dismiss the bookmarks screen. 534 // Dismiss the bookmarks screen.
535 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Exit")] 535 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Exit")]
536 performAction:grey_tap()]; 536 performAction:grey_tap()];
537 } 537 }
538 538
539 // Second, bookmark a page. 539 // Second, bookmark a page.
540 540
541 // Verify that the bookmark that is going to be added is not in the 541 // Verify that the bookmark that is going to be added is not in the
542 // BookmarkModel. 542 // BookmarkModel.
543 const GURL bookmarkedURL = web::test::HttpServer::MakeUrl( 543 const GURL bookmarkedURL = web::test::HttpServer::MakeUrl(
544 "http://ios/testing/data/http_server_files/fullscreen.html"); 544 "http://ios/testing/data/http_server_files/fullscreen.html");
545 NSString* const bookmarkedURLString = 545 NSString* const bookmarkedURLString =
546 base::SysUTF8ToNSString(bookmarkedURL.spec()); 546 base::SysUTF8ToNSString(bookmarkedURL.spec());
547 [[self class] assertBookmarksWithTitle:bookmarkedURLString expectedCount:0]; 547 [[self class] assertBookmarksWithTitle:bookmarkedURLString expectedCount:0];
548 // Open the page. 548 // Open the page.
549 std::string expectedURLContent = bookmarkedURL.GetContent(); 549 std::string expectedURLContent = bookmarkedURL.GetContent();
550 [ChromeEarlGrey loadURL:bookmarkedURL]; 550 [ChromeEarlGrey loadURL:bookmarkedURL];
551 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( 551 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
552 expectedURLContent)] 552 expectedURLContent)]
553 assertWithMatcher:grey_notNil()]; 553 assertWithMatcher:grey_notNil()];
554 554
555 // Verify that the folder has only one element. 555 // Verify that the folder has only one element.
556 [[self class] assertChildCount:1 ofFolderWithName:@"Sticky Folder"]; 556 [[self class] assertChildCount:1 ofFolderWithName:@"Sticky Folder"];
557 557
558 // Bookmark the page. 558 // Bookmark the page.
559 [[self class] starCurrentTab]; 559 [[self class] starCurrentTab];
560 560
561 // Verify the snackbar title. 561 // Verify the snackbar title.
(...skipping 12 matching lines...) Expand all
574 // are saved to the bookmark only when saving the results. 574 // are saved to the bookmark only when saving the results.
575 - (void)testMoveDoesSaveOnSave { 575 - (void)testMoveDoesSaveOnSave {
576 [[self class] setupStandardBookmarks]; 576 [[self class] setupStandardBookmarks];
577 [[self class] openTopLevelBookmarksFolder]; 577 [[self class] openTopLevelBookmarksFolder];
578 578
579 // Tap on the top-right button. 579 // Tap on the top-right button.
580 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 580 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
581 performAction:grey_tap()]; 581 performAction:grey_tap()];
582 582
583 // Tap the edit action. 583 // Tap the edit action.
584 [[EarlGrey selectElementWithMatcher:actionSheet(ActionEdit)] 584 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
585 performAction:grey_tap()]; 585 performAction:grey_tap()];
586 586
587 // Tap the Folder button. 587 // Tap the Folder button.
588 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")] 588 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")]
589 performAction:grey_tap()]; 589 performAction:grey_tap()];
590 590
591 // Create a new folder. 591 // Create a new folder.
592 [[self class] addFolderWithName:nil]; 592 [[self class] addFolderWithName:nil];
593 593
594 // Verify that the editor is present. 594 // Verify that the editor is present.
595 [[EarlGrey 595 [[EarlGrey
596 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 596 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
597 assertWithMatcher:grey_sufficientlyVisible()]; 597 assertWithMatcher:grey_sufficientlyVisible()];
598 598
599 // Check that the new folder doesn't contain the bookmark. 599 // Check that the new folder doesn't contain the bookmark.
600 [[self class] assertChildCount:0 ofFolderWithName:@"New Folder"]; 600 [[self class] assertChildCount:0 ofFolderWithName:@"New Folder"];
601 601
602 // Tap the Done button. 602 // Tap the Done button.
603 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 603 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
604 performAction:grey_tap()]; 604 performAction:grey_tap()];
605 [[EarlGrey 605 [[EarlGrey
606 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 606 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
607 assertWithMatcher:grey_notVisible()]; 607 assertWithMatcher:grey_notVisible()];
608 608
609 // Check that the new folder contains the bookmark. 609 // Check that the new folder contains the bookmark.
610 [[self class] assertChildCount:1 ofFolderWithName:@"New Folder"]; 610 [[self class] assertChildCount:1 ofFolderWithName:@"New Folder"];
611 611
612 // Dismiss the bookmarks screen. 612 // Dismiss the bookmarks screen.
613 if (IsCompact()) { 613 if (IsCompact()) {
614 // Dismiss the bookmarks screen. 614 // Dismiss the bookmarks screen.
615 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Exit")] 615 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Exit")]
616 performAction:grey_tap()]; 616 performAction:grey_tap()];
617 } 617 }
618 618
619 // Check that the new folder still contains the bookmark. 619 // Check that the new folder still contains the bookmark.
620 [[self class] assertChildCount:1 ofFolderWithName:@"New Folder"]; 620 [[self class] assertChildCount:1 ofFolderWithName:@"New Folder"];
621 } 621 }
622 622
623 // Test thats editing a single bookmark correctly persists data. 623 // Test thats editing a single bookmark correctly persists data.
624 - (void)testSingleBookmarkEdit { 624 - (void)testSingleBookmarkEdit {
625 [[self class] setupStandardBookmarks]; 625 [[self class] setupStandardBookmarks];
626 [[self class] openTopLevelBookmarksFolder]; 626 [[self class] openTopLevelBookmarksFolder];
627 627
628 // Load the menu for a bookmark. 628 // Load the menu for a bookmark.
629 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 629 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
630 performAction:grey_tap()]; 630 performAction:grey_tap()];
631 631
632 // Tap the edit action. 632 // Tap the edit action.
633 [[EarlGrey selectElementWithMatcher:actionSheet(ActionEdit)] 633 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
634 performAction:grey_tap()]; 634 performAction:grey_tap()];
635 635
636 // Replace the title field with new text. 636 // Replace the title field with new text.
637 // TODO(crbug.com/644730): Use grey_replaceText instead of 637 // TODO(crbug.com/644730): Use grey_replaceText instead of
638 // grey_clearText/grey_typeText when EarlGrey's issue is fixed: 638 // grey_clearText/grey_typeText when EarlGrey's issue is fixed:
639 // https://github.com/google/EarlGrey/issues/253 639 // https://github.com/google/EarlGrey/issues/253
640 [[EarlGrey 640 [[EarlGrey
641 selectElementWithMatcher:grey_accessibilityID(@"Title Field_textField")] 641 selectElementWithMatcher:grey_accessibilityID(@"Title Field_textField")]
642 performAction:grey_clearText()]; 642 performAction:grey_clearText()];
643 [[EarlGrey 643 [[EarlGrey
644 selectElementWithMatcher:grey_accessibilityID(@"Title Field_textField")] 644 selectElementWithMatcher:grey_accessibilityID(@"Title Field_textField")]
645 performAction:grey_typeText(@"n5")]; 645 performAction:grey_typeText(@"n5")];
646 646
647 // Replace the url field with new text. 647 // Replace the url field with new text.
648 // TODO(crbug.com/644730): Use grey_replaceText instead of 648 // TODO(crbug.com/644730): Use grey_replaceText instead of
649 // grey_clearText/grey_typeText when EarlGrey's issue is fixed: 649 // grey_clearText/grey_typeText when EarlGrey's issue is fixed:
650 // https://github.com/google/EarlGrey/issues/253 650 // https://github.com/google/EarlGrey/issues/253
651 [[EarlGrey 651 [[EarlGrey
652 selectElementWithMatcher:grey_accessibilityID(@"URL Field_textField")] 652 selectElementWithMatcher:grey_accessibilityID(@"URL Field_textField")]
653 performAction:grey_clearText()]; 653 performAction:grey_clearText()];
654 [[EarlGrey 654 [[EarlGrey
655 selectElementWithMatcher:grey_accessibilityID(@"URL Field_textField")] 655 selectElementWithMatcher:grey_accessibilityID(@"URL Field_textField")]
656 performAction:grey_typeText(@"www.a.fr")]; 656 performAction:grey_typeText(@"www.a.fr")];
657 657
658 // Dismiss editor. 658 // Dismiss editor.
659 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 659 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
660 performAction:grey_tap()]; 660 performAction:grey_tap()];
661 [[EarlGrey 661 [[EarlGrey
662 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 662 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
663 assertWithMatcher:grey_notVisible()]; 663 assertWithMatcher:grey_notVisible()];
664 664
665 // Verify that the bookmark was updated. 665 // Verify that the bookmark was updated.
666 [[EarlGrey selectElementWithMatcher:buttonWithAccessibilityLabel(@"n5")] 666 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"n5")]
667 assertWithMatcher:grey_sufficientlyVisible()]; 667 assertWithMatcher:grey_sufficientlyVisible()];
668 [[self class] assertExistenceOfBookmarkWithURL:@"http://www.a.fr" name:@"n5"]; 668 [[self class] assertExistenceOfBookmarkWithURL:@"http://www.a.fr" name:@"n5"];
669 } 669 }
670 670
671 // Tests that cancelling editing a single bookmark correctly doesn't persist 671 // Tests that cancelling editing a single bookmark correctly doesn't persist
672 // data. 672 // data.
673 - (void)testSingleBookmarkCancelEdit { 673 - (void)testSingleBookmarkCancelEdit {
674 [[self class] setupStandardBookmarks]; 674 [[self class] setupStandardBookmarks];
675 [[self class] openTopLevelBookmarksFolder]; 675 [[self class] openTopLevelBookmarksFolder];
676 676
677 // Load the menu for a bookmark. 677 // Load the menu for a bookmark.
678 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 678 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
679 performAction:grey_tap()]; 679 performAction:grey_tap()];
680 680
681 // Tap the edit action. 681 // Tap the edit action.
682 [[EarlGrey selectElementWithMatcher:actionSheet(ActionEdit)] 682 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
683 performAction:grey_tap()]; 683 performAction:grey_tap()];
684 684
685 // Replace the title field with new text. 685 // Replace the title field with new text.
686 // TODO(crbug.com/644730): Use grey_replaceText instead of 686 // TODO(crbug.com/644730): Use grey_replaceText instead of
687 // grey_clearText/grey_typeText when EarlGrey's issue is fixed: 687 // grey_clearText/grey_typeText when EarlGrey's issue is fixed:
688 // https://github.com/google/EarlGrey/issues/253 688 // https://github.com/google/EarlGrey/issues/253
689 [[EarlGrey 689 [[EarlGrey
690 selectElementWithMatcher:grey_accessibilityID(@"Title Field_textField")] 690 selectElementWithMatcher:grey_accessibilityID(@"Title Field_textField")]
691 performAction:grey_clearText()]; 691 performAction:grey_clearText()];
692 [[EarlGrey 692 [[EarlGrey
(...skipping 12 matching lines...) Expand all
705 performAction:grey_typeText(@"www.a.fr")]; 705 performAction:grey_typeText(@"www.a.fr")];
706 706
707 // Dismiss editor with Cancel button. 707 // Dismiss editor with Cancel button.
708 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Cancel")] 708 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Cancel")]
709 performAction:grey_tap()]; 709 performAction:grey_tap()];
710 [[EarlGrey 710 [[EarlGrey
711 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 711 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
712 assertWithMatcher:grey_notVisible()]; 712 assertWithMatcher:grey_notVisible()];
713 713
714 // Verify that the bookmark was not updated. 714 // Verify that the bookmark was not updated.
715 [[EarlGrey selectElementWithMatcher:buttonWithAccessibilityLabel(@"n5")] 715 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"n5")]
716 assertWithMatcher:grey_notVisible()]; 716 assertWithMatcher:grey_notVisible()];
717 [[self class] assertAbsenceOfBookmarkWithURL:@"http://www.a.fr"]; 717 [[self class] assertAbsenceOfBookmarkWithURL:@"http://www.a.fr"];
718 } 718 }
719 719
720 // Tests that long pressing a bookmark selects it and gives access to editing, 720 // Tests that long pressing a bookmark selects it and gives access to editing,
721 // as does the Info menu. 721 // as does the Info menu.
722 - (void)testLongPressBookmark { 722 - (void)testLongPressBookmark {
723 [[self class] setupStandardBookmarks]; 723 [[self class] setupStandardBookmarks];
724 [[self class] openTopLevelBookmarksFolder]; 724 [[self class] openTopLevelBookmarksFolder];
725 725
726 // Long press the top-right button. 726 // Long press the top-right button.
727 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 727 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
728 performAction:grey_longPress()]; 728 performAction:grey_longPress()];
729 729
730 // Tap the edit button. 730 // Tap the edit button.
731 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Edit_editing_bar")] 731 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Edit_editing_bar")]
732 performAction:grey_tap()]; 732 performAction:grey_tap()];
733 733
734 // Dismiss the editor screen. 734 // Dismiss the editor screen.
735 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 735 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
736 performAction:grey_tap()]; 736 performAction:grey_tap()];
737 737
738 // Tap on the top-right button. 738 // Tap on the top-right button.
739 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 739 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
740 performAction:grey_tap()]; 740 performAction:grey_tap()];
741 741
742 // Tap the edit action. 742 // Tap the edit action.
743 [[EarlGrey selectElementWithMatcher:actionSheet(ActionEdit)] 743 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
744 performAction:grey_tap()]; 744 performAction:grey_tap()];
745 745
746 // Dismiss the editor screen. 746 // Dismiss the editor screen.
747 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 747 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
748 performAction:grey_tap()]; 748 performAction:grey_tap()];
749 } 749 }
750 750
751 // Tests the editing of a folder. 751 // Tests the editing of a folder.
752 - (void)testEditFolder { 752 - (void)testEditFolder {
753 [[self class] setupStandardBookmarks]; 753 [[self class] setupStandardBookmarks];
754 [[self class] openBookmarkFolder:@"Folder 1"]; 754 [[self class] openBookmarkFolder:@"Folder 1"];
755 755
756 // Tap the Edit button in the navigation bar. 756 // Tap the Edit button in the navigation bar.
757 [[EarlGrey 757 [[EarlGrey
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 808
809 // Check that the folder doesn't exist anymore. 809 // Check that the folder doesn't exist anymore.
810 [[self class] assertFolderDoesntExistWithTitle:@"Folder 1"]; 810 [[self class] assertFolderDoesntExistWithTitle:@"Folder 1"];
811 } 811 }
812 812
813 // Navigates to a deeply nested folder, deletes it and makes sure the UI is 813 // Navigates to a deeply nested folder, deletes it and makes sure the UI is
814 // consistent. 814 // consistent.
815 - (void)testDeleteCurrentSubfolder { 815 - (void)testDeleteCurrentSubfolder {
816 [[self class] setupStandardBookmarks]; 816 [[self class] setupStandardBookmarks];
817 [[self class] openBookmarkFolder:@"Folder 1"]; 817 [[self class] openBookmarkFolder:@"Folder 1"];
818 [[EarlGrey selectElementWithMatcher:buttonWithAccessibilityLabel(@"Folder 2")] 818 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"Folder 2")]
819 performAction:grey_tap()]; 819 performAction:grey_tap()];
820 [[EarlGrey selectElementWithMatcher:buttonWithAccessibilityLabel(@"Folder 3")] 820 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"Folder 3")]
821 performAction:grey_tap()]; 821 performAction:grey_tap()];
822 822
823 // Delete the folder. 823 // Delete the folder.
824 [[self class] deleteSelectedFolder]; 824 [[self class] deleteSelectedFolder];
825 825
826 // Folder 3 is now deleted, UI should have moved to Folder 2, and Folder 2 826 // Folder 3 is now deleted, UI should have moved to Folder 2, and Folder 2
827 // should be empty. 827 // should be empty.
828 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Folder 2")] 828 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Folder 2")]
829 assertWithMatcher:grey_sufficientlyVisible()]; 829 assertWithMatcher:grey_sufficientlyVisible()];
830 [[self class] assertChildCount:0 ofFolderWithName:@"Folder 2"]; 830 [[self class] assertChildCount:0 ofFolderWithName:@"Folder 2"];
831 [[self class] assertFolderDoesntExistWithTitle:@"Folder 3"]; 831 [[self class] assertFolderDoesntExistWithTitle:@"Folder 3"];
832 [[self class] waitForDeletionOfBookmarkWithTitle:@"Folder 3"]; 832 [[self class] waitForDeletionOfBookmarkWithTitle:@"Folder 3"];
833 } 833 }
834 834
835 // Navigates to a deeply nested folder, delete its parent programatically. 835 // Navigates to a deeply nested folder, delete its parent programatically.
836 // Verifies that the UI is as expected. 836 // Verifies that the UI is as expected.
837 - (void)testDeleteParentFolder { 837 - (void)testDeleteParentFolder {
838 [[self class] setupStandardBookmarks]; 838 [[self class] setupStandardBookmarks];
839 [[self class] openBookmarkFolder:@"Folder 1"]; 839 [[self class] openBookmarkFolder:@"Folder 1"];
840 [[EarlGrey selectElementWithMatcher:buttonWithAccessibilityLabel(@"Folder 2")] 840 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"Folder 2")]
841 performAction:grey_tap()]; 841 performAction:grey_tap()];
842 [[EarlGrey selectElementWithMatcher:buttonWithAccessibilityLabel(@"Folder 3")] 842 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"Folder 3")]
843 performAction:grey_tap()]; 843 performAction:grey_tap()];
844 844
845 // Remove the parent programmatically. 845 // Remove the parent programmatically.
846 [[self class] removeBookmarkWithTitle:@"Folder 2"]; 846 [[self class] removeBookmarkWithTitle:@"Folder 2"];
847 847
848 // Folder 2 and 3 are now deleted, UI should have moved to Folder1, and 848 // Folder 2 and 3 are now deleted, UI should have moved to Folder1, and
849 // Folder 1 should be empty. 849 // Folder 1 should be empty.
850 [[EarlGrey 850 [[EarlGrey
851 selectElementWithMatcher:grey_allOf( 851 selectElementWithMatcher:grey_allOf(
852 grey_kindOfClass(NSClassFromString( 852 grey_kindOfClass(NSClassFromString(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 // Tests moving a bookmark into a new folder created in the moving process. 919 // Tests moving a bookmark into a new folder created in the moving process.
920 - (void)testCreateNewFolderWhileMovingBookmark { 920 - (void)testCreateNewFolderWhileMovingBookmark {
921 [[self class] setupStandardBookmarks]; 921 [[self class] setupStandardBookmarks];
922 [[self class] openMobileBookmarks]; 922 [[self class] openMobileBookmarks];
923 923
924 // Tap the info disclosure indicator for the bookmark we want to move. 924 // Tap the info disclosure indicator for the bookmark we want to move.
925 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 925 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
926 performAction:grey_tap()]; 926 performAction:grey_tap()];
927 927
928 // Choose to move the bookmark in the context menu. 928 // Choose to move the bookmark in the context menu.
929 [[EarlGrey selectElementWithMatcher:actionSheet(ActionMove)] 929 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionMove)]
930 performAction:grey_tap()]; 930 performAction:grey_tap()];
931 931
932 // Choose to move the bookmark into a new folder. 932 // Choose to move the bookmark into a new folder.
933 [[EarlGrey 933 [[EarlGrey
934 selectElementWithMatcher:grey_accessibilityID(@"Create New Folder")] 934 selectElementWithMatcher:grey_accessibilityID(@"Create New Folder")]
935 performAction:grey_tap()]; 935 performAction:grey_tap()];
936 936
937 // Enter custom new folder name. 937 // Enter custom new folder name.
938 [[self class] renameBookmarkFolderWithFolderTitle:@"Title For New Folder"]; 938 [[self class] renameBookmarkFolderWithFolderTitle:@"Title For New Folder"];
939 939
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 - (void)testKeyboardCommandsNotRegistered_EditBookmark { 1067 - (void)testKeyboardCommandsNotRegistered_EditBookmark {
1068 [[self class] setupStandardBookmarks]; 1068 [[self class] setupStandardBookmarks];
1069 [[self class] openMobileBookmarks]; 1069 [[self class] openMobileBookmarks];
1070 1070
1071 // Go to a bookmarked page. Tap on one of the standard bookmark. 1071 // Go to a bookmarked page. Tap on one of the standard bookmark.
1072 [[EarlGrey selectElementWithMatcher:grey_text(@"Second URL")] 1072 [[EarlGrey selectElementWithMatcher:grey_text(@"Second URL")]
1073 performAction:grey_tap()]; 1073 performAction:grey_tap()];
1074 1074
1075 // Edit the bookmark. 1075 // Edit the bookmark.
1076 if (!IsCompact()) { 1076 if (!IsCompact()) {
1077 [[EarlGrey selectElementWithMatcher:starButton()] performAction:grey_tap()]; 1077 [[EarlGrey selectElementWithMatcher:StarButton()] performAction:grey_tap()];
1078 } else { 1078 } else {
1079 [ChromeEarlGreyUI openToolsMenu]; 1079 [ChromeEarlGreyUI openToolsMenu];
1080 [[EarlGrey selectElementWithMatcher:litStarButtoniPhone()] 1080 [[EarlGrey selectElementWithMatcher:LitStarButtoniPhone()]
1081 performAction:grey_tap()]; 1081 performAction:grey_tap()];
1082 } 1082 }
1083 GREYAssertTrue(chrome_test_util::GetRegisteredKeyCommandsCount() == 0, 1083 GREYAssertTrue(chrome_test_util::GetRegisteredKeyCommandsCount() == 0,
1084 @"No keyboard commands are registered."); 1084 @"No keyboard commands are registered.");
1085 } 1085 }
1086 1086
1087 // Tests that tapping No thanks on the promo make it disappear. 1087 // Tests that tapping No thanks on the promo make it disappear.
1088 - (void)testPromoNoThanksMakeItDisappear { 1088 - (void)testPromoNoThanksMakeItDisappear {
1089 [[self class] setupStandardBookmarks]; 1089 [[self class] setupStandardBookmarks];
1090 [[self class] openTopLevelBookmarksFolder]; 1090 [[self class] openTopLevelBookmarksFolder];
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 [[self class] verifyPromoAlreadySeen:NO]; 1148 [[self class] verifyPromoAlreadySeen:NO];
1149 } 1149 }
1150 1150
1151 // Tests that all elements on the bookmarks landing page are accessible. 1151 // Tests that all elements on the bookmarks landing page are accessible.
1152 - (void)testAccessibilityOnBookmarksLandingPage { 1152 - (void)testAccessibilityOnBookmarksLandingPage {
1153 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark]; 1153 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark];
1154 1154
1155 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 1155 chrome_test_util::VerifyAccessibilityForCurrentScreen();
1156 if (IsCompact()) { 1156 if (IsCompact()) {
1157 // Exit from bookmarks modal. IPad shows bookmarks in tab. 1157 // Exit from bookmarks modal. IPad shows bookmarks in tab.
1158 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 1158 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1159 performAction:grey_tap()]; 1159 performAction:grey_tap()];
1160 } 1160 }
1161 } 1161 }
1162 1162
1163 // Tests that all elements on the bookmarks Edit page are accessible. 1163 // Tests that all elements on the bookmarks Edit page are accessible.
1164 - (void)testAccessibilityOnBookmarksEditPage { 1164 - (void)testAccessibilityOnBookmarksEditPage {
1165 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark]; 1165 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark];
1166 1166
1167 // Load the menu for a bookmark. 1167 // Load the menu for a bookmark.
1168 [[EarlGrey selectElementWithMatcher:moreMenuButton()] 1168 [[EarlGrey selectElementWithMatcher:MoreMenuButton()]
1169 performAction:grey_tap()]; 1169 performAction:grey_tap()];
1170 1170
1171 // Tap the edit action. 1171 // Tap the edit action.
1172 [[EarlGrey selectElementWithMatcher:actionSheet(ActionEdit)] 1172 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
1173 performAction:grey_tap()]; 1173 performAction:grey_tap()];
1174 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 1174 chrome_test_util::VerifyAccessibilityForCurrentScreen();
1175 if (IsCompact()) { 1175 if (IsCompact()) {
1176 // Exit from bookmarks modal. IPad shows bookmarks in tab. 1176 // Exit from bookmarks modal. IPad shows bookmarks in tab.
1177 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 1177 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1178 performAction:grey_tap()]; 1178 performAction:grey_tap()];
1179 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 1179 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1180 performAction:grey_tap()]; 1180 performAction:grey_tap()];
1181 } 1181 }
1182 } 1182 }
1183 1183
1184 // Tests that all elements on the bookmarks Move page are accessible. 1184 // Tests that all elements on the bookmarks Move page are accessible.
1185 - (void)testAccessibilityOnBookmarksMovePage { 1185 - (void)testAccessibilityOnBookmarksMovePage {
1186 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark]; 1186 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark];
1187 1187
1188 // Load the menu for a bookmark. 1188 // Load the menu for a bookmark.
1189 [[EarlGrey selectElementWithMatcher:moreMenuButton()] 1189 [[EarlGrey selectElementWithMatcher:MoreMenuButton()]
1190 performAction:grey_tap()]; 1190 performAction:grey_tap()];
1191 1191
1192 // Tap the Move action. 1192 // Tap the Move action.
1193 [[EarlGrey selectElementWithMatcher:actionSheet(ActionMove)] 1193 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionMove)]
1194 performAction:grey_tap()]; 1194 performAction:grey_tap()];
1195 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 1195 chrome_test_util::VerifyAccessibilityForCurrentScreen();
1196 if (IsCompact()) { 1196 if (IsCompact()) {
1197 // Exit from bookmarks modal. IPad shows bookmarks in tab. 1197 // Exit from bookmarks modal. IPad shows bookmarks in tab.
1198 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 1198 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1199 performAction:grey_tap()]; 1199 performAction:grey_tap()];
1200 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 1200 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1201 performAction:grey_tap()]; 1201 performAction:grey_tap()];
1202 } 1202 }
1203 } 1203 }
1204 1204
1205 // Tests that all elements on the bookmarks Move to New Folder page are 1205 // Tests that all elements on the bookmarks Move to New Folder page are
1206 // accessible. 1206 // accessible.
1207 - (void)testAccessibilityOnBookmarksMoveToNewFolderPage { 1207 - (void)testAccessibilityOnBookmarksMoveToNewFolderPage {
1208 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark]; 1208 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark];
1209 1209
1210 // Load the menu for a bookmark. 1210 // Load the menu for a bookmark.
1211 [[EarlGrey selectElementWithMatcher:moreMenuButton()] 1211 [[EarlGrey selectElementWithMatcher:MoreMenuButton()]
1212 performAction:grey_tap()]; 1212 performAction:grey_tap()];
1213 1213
1214 // Tap the Move action. 1214 // Tap the Move action.
1215 [[EarlGrey selectElementWithMatcher:actionSheet(ActionMove)] 1215 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionMove)]
1216 performAction:grey_tap()]; 1216 performAction:grey_tap()];
1217 // Tap on "Create New Folder." 1217 // Tap on "Create New Folder."
1218 [[EarlGrey 1218 [[EarlGrey
1219 selectElementWithMatcher:grey_accessibilityID(@"Create New Folder")] 1219 selectElementWithMatcher:grey_accessibilityID(@"Create New Folder")]
1220 performAction:grey_tap()]; 1220 performAction:grey_tap()];
1221 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 1221 chrome_test_util::VerifyAccessibilityForCurrentScreen();
1222 if (IsCompact()) { 1222 if (IsCompact()) {
1223 // Exit from bookmarks modal. IPad shows bookmarks in tab. 1223 // Exit from bookmarks modal. IPad shows bookmarks in tab.
1224 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 1224 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1225 performAction:grey_tap()]; 1225 performAction:grey_tap()];
1226 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 1226 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1227 performAction:grey_tap()]; 1227 performAction:grey_tap()];
1228 } 1228 }
1229 } 1229 }
1230 1230
1231 // Tests that all elements on bookmarks Delete and Undo are accessible. 1231 // Tests that all elements on bookmarks Delete and Undo are accessible.
1232 - (void)testAccessibilityOnBookmarksDeleteUndo { 1232 - (void)testAccessibilityOnBookmarksDeleteUndo {
1233 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark]; 1233 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark];
1234 1234
1235 // Load the menu for a bookmark. 1235 // Load the menu for a bookmark.
1236 [[EarlGrey selectElementWithMatcher:moreMenuButton()] 1236 [[EarlGrey selectElementWithMatcher:MoreMenuButton()]
1237 performAction:grey_tap()]; 1237 performAction:grey_tap()];
1238 1238
1239 // Tap the Delete action. 1239 // Tap the Delete action.
1240 [[EarlGrey selectElementWithMatcher:actionSheet(ActionDelete)] 1240 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionDelete)]
1241 performAction:grey_tap()]; 1241 performAction:grey_tap()];
1242 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 1242 chrome_test_util::VerifyAccessibilityForCurrentScreen();
1243 if (IsCompact()) { 1243 if (IsCompact()) {
1244 // Exit from bookmarks modal. IPad shows bookmarks in tab. 1244 // Exit from bookmarks modal. IPad shows bookmarks in tab.
1245 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 1245 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1246 performAction:grey_tap()]; 1246 performAction:grey_tap()];
1247 } 1247 }
1248 } 1248 }
1249 1249
1250 // Tests that all elements on the bookmarks Select page are accessible. 1250 // Tests that all elements on the bookmarks Select page are accessible.
1251 - (void)testAccessibilityOnBookmarksSelect { 1251 - (void)testAccessibilityOnBookmarksSelect {
1252 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark]; 1252 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark];
1253 1253
1254 // Load the menu for a bookmark. 1254 // Load the menu for a bookmark.
1255 [[EarlGrey selectElementWithMatcher:moreMenuButton()] 1255 [[EarlGrey selectElementWithMatcher:MoreMenuButton()]
1256 performAction:grey_tap()]; 1256 performAction:grey_tap()];
1257 1257
1258 // Tap the Select action. 1258 // Tap the Select action.
1259 [[EarlGrey selectElementWithMatcher:actionSheet(ActionSelect)] 1259 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionSelect)]
1260 performAction:grey_tap()]; 1260 performAction:grey_tap()];
1261 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 1261 chrome_test_util::VerifyAccessibilityForCurrentScreen();
1262 // Dismiss selector with Cancel button. 1262 // Dismiss selector with Cancel button.
1263 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Exit Edit Mode")] 1263 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Exit Edit Mode")]
1264 performAction:grey_tap()]; 1264 performAction:grey_tap()];
1265 } 1265 }
1266 1266
1267 #pragma mark Helper Methods 1267 #pragma mark Helper Methods
1268 1268
1269 // Navigates to the bookmark manager UI. 1269 // Navigates to the bookmark manager UI.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 "http://ios/testing/data/http_server_files/destination.html"); 1320 "http://ios/testing/data/http_server_files/destination.html");
1321 NSString* bookmarkTitle = @"smokeTapBookmark"; 1321 NSString* bookmarkTitle = @"smokeTapBookmark";
1322 // Load a bookmark into the bookmark model. 1322 // Load a bookmark into the bookmark model.
1323 [[self class] addBookmark:bookmarkURL withTitle:bookmarkTitle]; 1323 [[self class] addBookmark:bookmarkURL withTitle:bookmarkTitle];
1324 1324
1325 // Open the UI for Bookmarks. 1325 // Open the UI for Bookmarks.
1326 [[self class] openMobileBookmarks]; 1326 [[self class] openMobileBookmarks];
1327 1327
1328 // Verify bookmark is visible. 1328 // Verify bookmark is visible.
1329 [[EarlGrey 1329 [[EarlGrey
1330 selectElementWithMatcher:buttonWithAccessibilityLabel(bookmarkTitle)] 1330 selectElementWithMatcher:ButtonWithAccessibilityLabel(bookmarkTitle)]
1331 assertWithMatcher:grey_sufficientlyVisible() 1331 assertWithMatcher:grey_sufficientlyVisible()
1332 error:nil]; 1332 error:nil];
1333 } 1333 }
1334 1334
1335 // Navigates to the edit folder UI for |folderTitle|. 1335 // Navigates to the edit folder UI for |folderTitle|.
1336 + (void)openEditBookmarkFolderWithFolderTitle:(NSString*)folderTitle { 1336 + (void)openEditBookmarkFolderWithFolderTitle:(NSString*)folderTitle {
1337 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(folderTitle)] 1337 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(folderTitle)]
1338 performAction:grey_tap()]; 1338 performAction:grey_tap()];
1339 [[EarlGrey selectElementWithMatcher:editBookmarkButton()] 1339 [[EarlGrey selectElementWithMatcher:EditBookmarkButton()]
1340 performAction:grey_tap()]; 1340 performAction:grey_tap()];
1341 } 1341 }
1342 1342
1343 // Dismisses the edit folder UI. 1343 // Dismisses the edit folder UI.
1344 + (void)closeEditBookmarkFolder { 1344 + (void)closeEditBookmarkFolder {
1345 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 1345 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1346 performAction:grey_tap()]; 1346 performAction:grey_tap()];
1347 } 1347 }
1348 1348
1349 // Rename folder title to |folderTitle|. Must be in edit folder UI. 1349 // Rename folder title to |folderTitle|. Must be in edit folder UI.
1350 + (void)renameBookmarkFolderWithFolderTitle:(NSString*)folderTitle { 1350 + (void)renameBookmarkFolderWithFolderTitle:(NSString*)folderTitle {
1351 NSString* titleIdentifier = @"Title_textField"; 1351 NSString* titleIdentifier = @"Title_textField";
1352 NSString* clearTextFieldIdentifier = @"Clear text"; 1352 NSString* clearTextFieldIdentifier = @"Clear text";
1353 1353
1354 // Edit the title field. 1354 // Edit the title field.
1355 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(titleIdentifier)] 1355 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(titleIdentifier)]
(...skipping 10 matching lines...) Expand all
1366 } 1366 }
1367 1367
1368 // Tap on the star to bookmark a page, then edit the bookmark to change the 1368 // Tap on the star to bookmark a page, then edit the bookmark to change the
1369 // title to |title|. 1369 // title to |title|.
1370 + (void)bookmarkCurrentTabWithTitle:(NSString*)title { 1370 + (void)bookmarkCurrentTabWithTitle:(NSString*)title {
1371 [[self class] waitForBookmarkModelLoaded:YES]; 1371 [[self class] waitForBookmarkModelLoaded:YES];
1372 // Add the bookmark from the UI. 1372 // Add the bookmark from the UI.
1373 [[self class] starCurrentTab]; 1373 [[self class] starCurrentTab];
1374 1374
1375 // Set the bookmark name. 1375 // Set the bookmark name.
1376 [[EarlGrey selectElementWithMatcher:editBookmarkButton()] 1376 [[EarlGrey selectElementWithMatcher:EditBookmarkButton()]
1377 performAction:grey_tap()]; 1377 performAction:grey_tap()];
1378 NSString* titleIdentifier = @"Title Field_textField"; 1378 NSString* titleIdentifier = @"Title Field_textField";
1379 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(titleIdentifier)] 1379 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(titleIdentifier)]
1380 performAction:grey_tap()]; 1380 performAction:grey_tap()];
1381 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Clear text")] 1381 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Clear text")]
1382 performAction:grey_tap()]; 1382 performAction:grey_tap()];
1383 1383
1384 // Use '\n' to tap Done and dismiss the keyboard. 1384 // Use '\n' to tap Done and dismiss the keyboard.
1385 NSString* bookmarkTitle = [NSString stringWithFormat:@"%@\n", title]; 1385 NSString* bookmarkTitle = [NSString stringWithFormat:@"%@\n", title];
1386 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(titleIdentifier)] 1386 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(titleIdentifier)]
1387 performAction:grey_typeText(bookmarkTitle)]; 1387 performAction:grey_typeText(bookmarkTitle)];
1388 1388
1389 // Dismiss the window. 1389 // Dismiss the window.
1390 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] 1390 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1391 performAction:grey_tap()]; 1391 performAction:grey_tap()];
1392 } 1392 }
1393 1393
1394 // Waits for the bookmark model to be loaded in memory. 1394 // Waits for the bookmark model to be loaded in memory.
1395 + (void)waitForBookmarkModelLoaded:(BOOL)loaded { 1395 + (void)waitForBookmarkModelLoaded:(BOOL)loaded {
1396 bookmarks::BookmarkModel* bookmarkModel = 1396 bookmarks::BookmarkModel* bookmarkModel =
1397 ios::BookmarkModelFactory::GetForBrowserState( 1397 ios::BookmarkModelFactory::GetForBrowserState(
1398 chrome_test_util::GetOriginalBrowserState()); 1398 chrome_test_util::GetOriginalBrowserState());
1399 GREYAssert(testing::WaitUntilConditionOrTimeout( 1399 GREYAssert(testing::WaitUntilConditionOrTimeout(
1400 testing::kWaitForUIElementTimeout, 1400 testing::kWaitForUIElementTimeout,
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 error:&error]; 1683 error:&error];
1684 return error == nil; 1684 return error == nil;
1685 }; 1685 };
1686 GREYAssert(testing::WaitUntilConditionOrTimeout(10, condition), 1686 GREYAssert(testing::WaitUntilConditionOrTimeout(10, condition),
1687 @"Waiting for bookmark to go away"); 1687 @"Waiting for bookmark to go away");
1688 } 1688 }
1689 1689
1690 // Adds a bookmark for the current tab. Must be called when on a tab. 1690 // Adds a bookmark for the current tab. Must be called when on a tab.
1691 + (void)starCurrentTab { 1691 + (void)starCurrentTab {
1692 if (!IsCompact()) { 1692 if (!IsCompact()) {
1693 [[EarlGrey selectElementWithMatcher:starButton()] performAction:grey_tap()]; 1693 [[EarlGrey selectElementWithMatcher:StarButton()] performAction:grey_tap()];
1694 } else { 1694 } else {
1695 [ChromeEarlGreyUI openToolsMenu]; 1695 [ChromeEarlGreyUI openToolsMenu];
1696 [[EarlGrey selectElementWithMatcher:addBookmarkButton()] 1696 [[EarlGrey selectElementWithMatcher:AddBookmarkButton()]
1697 performAction:grey_tap()]; 1697 performAction:grey_tap()];
1698 } 1698 }
1699 } 1699 }
1700 1700
1701 @end 1701 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698