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

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

Issue 2677293002: [ObjC ARC] Converts ios/chrome/browser/ui/bookmarks:eg_tests to ARC. (Closed)
Patch Set: 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
« no previous file with comments | « ios/chrome/browser/ui/bookmarks/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if !defined(__has_feature) || !__has_feature(objc_arc)
46 #error "This file requires ARC support."
47 #endif
48
45 using chrome_test_util::ButtonWithAccessibilityLabel; 49 using chrome_test_util::ButtonWithAccessibilityLabel;
46 using chrome_test_util::ButtonWithAccessibilityLabelId; 50 using chrome_test_util::ButtonWithAccessibilityLabelId;
47 51
48 namespace { 52 namespace {
49 // TODO(crbug.com/616929): Move common matchers that are useful across tests 53 // TODO(crbug.com/616929): Move common matchers that are useful across tests
50 // into a shared location. 54 // into a shared location.
51 55
52 // Matcher for bookmarks tool tip star. 56 // Matcher for bookmarks tool tip star.
53 id<GREYMatcher> StarButton() { 57 id<GREYMatcher> StarButton() {
54 return ButtonWithAccessibilityLabelId(IDS_TOOLTIP_STAR); 58 return ButtonWithAccessibilityLabelId(IDS_TOOLTIP_STAR);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 "http://ios/testing/data/http_server_files/pony.html"); 164 "http://ios/testing/data/http_server_files/pony.html");
161 std::string expectedURLContent = bookmarkedURL.GetContent(); 165 std::string expectedURLContent = bookmarkedURL.GetContent();
162 NSString* bookmarkTitle = @"my bookmark"; 166 NSString* bookmarkTitle = @"my bookmark";
163 167
164 [ChromeEarlGrey loadURL:bookmarkedURL]; 168 [ChromeEarlGrey loadURL:bookmarkedURL];
165 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 169 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
166 expectedURLContent)] 170 expectedURLContent)]
167 assertWithMatcher:grey_notNil()]; 171 assertWithMatcher:grey_notNil()];
168 172
169 // Add the bookmark from the UI. 173 // Add the bookmark from the UI.
170 [[self class] bookmarkCurrentTabWithTitle:bookmarkTitle]; 174 [BookmarksTestCase bookmarkCurrentTabWithTitle:bookmarkTitle];
171 175
172 // Verify the bookmark is set. 176 // Verify the bookmark is set.
173 [[self class] assertBookmarksWithTitle:bookmarkTitle expectedCount:1]; 177 [BookmarksTestCase assertBookmarksWithTitle:bookmarkTitle expectedCount:1];
174 178
175 NSString* const kStarLitLabel = 179 NSString* const kStarLitLabel =
176 !IsCompact() ? l10n_util::GetNSString(IDS_TOOLTIP_STAR) 180 !IsCompact() ? l10n_util::GetNSString(IDS_TOOLTIP_STAR)
177 : l10n_util::GetNSString(IDS_IOS_BOOKMARK_EDIT_SCREEN_TITLE); 181 : l10n_util::GetNSString(IDS_IOS_BOOKMARK_EDIT_SCREEN_TITLE);
178 // Verify the star is lit. 182 // Verify the star is lit.
179 if (IsCompact()) { 183 if (IsCompact()) {
180 [ChromeEarlGreyUI openToolsMenu]; 184 [ChromeEarlGreyUI openToolsMenu];
181 } 185 }
182 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(kStarLitLabel)] 186 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(kStarLitLabel)]
183 assertWithMatcher:grey_notNil()]; 187 assertWithMatcher:grey_notNil()];
184 188
185 // Clear the bookmark via the UI. 189 // Clear the bookmark via the UI.
186 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(kStarLitLabel)] 190 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(kStarLitLabel)]
187 performAction:grey_tap()]; 191 performAction:grey_tap()];
188 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionDelete)] 192 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionDelete)]
189 performAction:grey_tap()]; 193 performAction:grey_tap()];
190 194
191 // Verify the bookmark is not in the BookmarkModel. 195 // Verify the bookmark is not in the BookmarkModel.
192 [[self class] assertBookmarksWithTitle:bookmarkTitle expectedCount:0]; 196 [BookmarksTestCase assertBookmarksWithTitle:bookmarkTitle expectedCount:0];
193 197
194 NSString* const kStarUnlitLabel = 198 NSString* const kStarUnlitLabel =
195 !IsCompact() ? l10n_util::GetNSString(IDS_TOOLTIP_STAR) 199 !IsCompact() ? l10n_util::GetNSString(IDS_TOOLTIP_STAR)
196 : l10n_util::GetNSString(IDS_BOOKMARK_ADD_EDITOR_TITLE); 200 : l10n_util::GetNSString(IDS_BOOKMARK_ADD_EDITOR_TITLE);
197 201
198 // Verify the star is not lit. 202 // Verify the star is not lit.
199 if (IsCompact()) { 203 if (IsCompact()) {
200 [ChromeEarlGreyUI openToolsMenu]; 204 [ChromeEarlGreyUI openToolsMenu];
201 } 205 }
202 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(kStarUnlitLabel)] 206 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(kStarUnlitLabel)]
203 assertWithMatcher:grey_notNil()]; 207 assertWithMatcher:grey_notNil()];
204 208
205 // TODO(crbug.com/617652): This code should be removed when a common helper 209 // 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. 210 // is added to close any menus, which should be run as test setup.
207 if (IsCompact()) { 211 if (IsCompact()) {
208 [[EarlGrey selectElementWithMatcher:CloseToolsMenuButton()] 212 [[EarlGrey selectElementWithMatcher:CloseToolsMenuButton()]
209 performAction:grey_tap()]; 213 performAction:grey_tap()];
210 } 214 }
211 215
212 // Close the opened tab. 216 // Close the opened tab.
213 base::scoped_nsobject<GenericChromeCommand> command( 217 GenericChromeCommand* command =
214 [[GenericChromeCommand alloc] initWithTag:IDC_CLOSE_TAB]); 218 [[GenericChromeCommand alloc] initWithTag:IDC_CLOSE_TAB];
215 chrome_test_util::RunCommandWithActiveViewController(command); 219 chrome_test_util::RunCommandWithActiveViewController(command);
216 } 220 }
217 221
218 // Tests that tapping a bookmark on the NTP navigates to the proper URL. 222 // Tests that tapping a bookmark on the NTP navigates to the proper URL.
219 - (void)testTapBookmark { 223 - (void)testTapBookmark {
220 const GURL bookmarkURL = web::test::HttpServer::MakeUrl( 224 const GURL bookmarkURL = web::test::HttpServer::MakeUrl(
221 "http://ios/testing/data/http_server_files/destination.html"); 225 "http://ios/testing/data/http_server_files/destination.html");
222 NSString* bookmarkTitle = @"smokeTapBookmark"; 226 NSString* bookmarkTitle = @"smokeTapBookmark";
223 227
224 // Load a bookmark into the bookmark model. 228 // Load a bookmark into the bookmark model.
225 [[self class] addBookmark:bookmarkURL withTitle:bookmarkTitle]; 229 [BookmarksTestCase addBookmark:bookmarkURL withTitle:bookmarkTitle];
226 230
227 // Open the UI for Bookmarks. 231 // Open the UI for Bookmarks.
228 [[self class] openMobileBookmarks]; 232 [BookmarksTestCase openMobileBookmarks];
229 233
230 // Verify bookmark is visible. 234 // Verify bookmark is visible.
231 [[EarlGrey 235 [[EarlGrey
232 selectElementWithMatcher:ButtonWithAccessibilityLabel(bookmarkTitle)] 236 selectElementWithMatcher:ButtonWithAccessibilityLabel(bookmarkTitle)]
233 assertWithMatcher:grey_sufficientlyVisible() 237 assertWithMatcher:grey_sufficientlyVisible()
234 error:nil]; 238 error:nil];
235 239
236 // Tap on the bookmark and verify the URL that appears in the omnibox. 240 // Tap on the bookmark and verify the URL that appears in the omnibox.
237 [[EarlGrey 241 [[EarlGrey
238 selectElementWithMatcher:ButtonWithAccessibilityLabel(bookmarkTitle)] 242 selectElementWithMatcher:ButtonWithAccessibilityLabel(bookmarkTitle)]
239 performAction:grey_tap()]; 243 performAction:grey_tap()];
240 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 244 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
241 bookmarkURL.GetContent())] 245 bookmarkURL.GetContent())]
242 assertWithMatcher:grey_notNil()]; 246 assertWithMatcher:grey_notNil()];
243 } 247 }
244 248
245 // Test to set bookmarks in multiple tabs. 249 // Test to set bookmarks in multiple tabs.
246 - (void)testBookmarkMultipleTabs { 250 - (void)testBookmarkMultipleTabs {
247 const GURL firstURL = web::test::HttpServer::MakeUrl( 251 const GURL firstURL = web::test::HttpServer::MakeUrl(
248 "http://ios/testing/data/http_server_files/pony.html"); 252 "http://ios/testing/data/http_server_files/pony.html");
249 const GURL secondURL = web::test::HttpServer::MakeUrl( 253 const GURL secondURL = web::test::HttpServer::MakeUrl(
250 "http://ios/testing/data/http_server_files/destination.html"); 254 "http://ios/testing/data/http_server_files/destination.html");
251 [ChromeEarlGrey loadURL:firstURL]; 255 [ChromeEarlGrey loadURL:firstURL];
252 chrome_test_util::OpenNewTab(); 256 chrome_test_util::OpenNewTab();
253 [ChromeEarlGrey loadURL:secondURL]; 257 [ChromeEarlGrey loadURL:secondURL];
254 258
255 [[self class] bookmarkCurrentTabWithTitle:@"my bookmark"]; 259 [BookmarksTestCase bookmarkCurrentTabWithTitle:@"my bookmark"];
256 [[self class] assertBookmarksWithTitle:@"my bookmark" expectedCount:1]; 260 [BookmarksTestCase assertBookmarksWithTitle:@"my bookmark" expectedCount:1];
257 } 261 }
258 262
259 // Try navigating to the bookmark screen, and selecting a bookmark. 263 // Try navigating to the bookmark screen, and selecting a bookmark.
260 - (void)testSelectBookmark { 264 - (void)testSelectBookmark {
261 [[self class] setupStandardBookmarks]; 265 [BookmarksTestCase setupStandardBookmarks];
262 [[self class] openMobileBookmarks]; 266 [BookmarksTestCase openMobileBookmarks];
263 267
264 // Tap on one of the standard bookmark. Verify that it loads. 268 // Tap on one of the standard bookmark. Verify that it loads.
265 [[EarlGrey selectElementWithMatcher:grey_text(@"Second URL")] 269 [[EarlGrey selectElementWithMatcher:grey_text(@"Second URL")]
266 performAction:grey_tap()]; 270 performAction:grey_tap()];
267 271
268 // Wait for the page to load. 272 // Wait for the page to load.
269 [ChromeEarlGrey waitForPageToFinishLoading]; 273 [ChromeEarlGrey waitForPageToFinishLoading];
270 274
271 // Check the URL is correct. 275 // Check the URL is correct.
272 const GURL secondURL = web::test::HttpServer::MakeUrl( 276 const GURL secondURL = web::test::HttpServer::MakeUrl(
273 "http://ios/testing/data/http_server_files/destination.html"); 277 "http://ios/testing/data/http_server_files/destination.html");
274 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()] 278 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
275 assertWithMatcher:chrome_test_util::OmniboxText(secondURL.GetContent())]; 279 assertWithMatcher:chrome_test_util::OmniboxText(secondURL.GetContent())];
276 } 280 }
277 281
278 // Try deleting a bookmark, then undoing that delete. 282 // Try deleting a bookmark, then undoing that delete.
279 - (void)testUndoDeleteBookmark { 283 - (void)testUndoDeleteBookmark {
280 [[self class] setupStandardBookmarks]; 284 [BookmarksTestCase setupStandardBookmarks];
281 [[self class] openMobileBookmarks]; 285 [BookmarksTestCase openMobileBookmarks];
282 286
283 // Load the menu for a bookmark. 287 // Load the menu for a bookmark.
284 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL Info")] 288 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL Info")]
285 performAction:grey_tap()]; 289 performAction:grey_tap()];
286 290
287 // Delete it. 291 // Delete it.
288 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionDelete)] 292 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionDelete)]
289 performAction:grey_tap()]; 293 performAction:grey_tap()];
290 294
291 // Wait until it's gone. 295 // Wait until it's gone.
292 [[self class] waitForDeletionOfBookmarkWithTitle:@"Second URL"]; 296 [BookmarksTestCase waitForDeletionOfBookmarkWithTitle:@"Second URL"];
293 297
294 // Press undo 298 // Press undo
295 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Undo")] 299 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Undo")]
296 performAction:grey_tap()]; 300 performAction:grey_tap()];
297 301
298 // Verify it's back. 302 // Verify it's back.
299 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL")] 303 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL")]
300 assertWithMatcher:grey_notNil()]; 304 assertWithMatcher:grey_notNil()];
301 } 305 }
302 306
303 // Try deleting a bookmark from the edit screen, then undoing that delete. 307 // Try deleting a bookmark from the edit screen, then undoing that delete.
304 - (void)testUndoDeleteBookmarkFromEditScreen { 308 - (void)testUndoDeleteBookmarkFromEditScreen {
305 [[self class] setupStandardBookmarks]; 309 [BookmarksTestCase setupStandardBookmarks];
306 [[self class] openMobileBookmarks]; 310 [BookmarksTestCase openMobileBookmarks];
307 311
308 // Load the menu for a bookmark. 312 // Load the menu for a bookmark.
309 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL Info")] 313 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL Info")]
310 performAction:grey_tap()]; 314 performAction:grey_tap()];
311 315
312 // Tap the edit action. 316 // Tap the edit action.
313 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)] 317 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
314 performAction:grey_tap()]; 318 performAction:grey_tap()];
315 319
316 // Delete it. 320 // Delete it.
(...skipping 15 matching lines...) Expand all
332 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Undo")] 336 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Undo")]
333 performAction:grey_tap()]; 337 performAction:grey_tap()];
334 338
335 // Verify it's back. 339 // Verify it's back.
336 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL")] 340 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL")]
337 assertWithMatcher:grey_notNil()]; 341 assertWithMatcher:grey_notNil()];
338 } 342 }
339 343
340 // Try moving bookmarks, then undoing that move. 344 // Try moving bookmarks, then undoing that move.
341 - (void)testUndoMoveBookmark { 345 - (void)testUndoMoveBookmark {
342 [[self class] setupStandardBookmarks]; 346 [BookmarksTestCase setupStandardBookmarks];
343 [[self class] openMobileBookmarks]; 347 [BookmarksTestCase openMobileBookmarks];
344 348
345 // Verify that folder 2 only has 1 child. 349 // Verify that folder 2 only has 1 child.
346 [[self class] assertChildCount:1 ofFolderWithName:@"Folder 2"]; 350 [BookmarksTestCase assertChildCount:1 ofFolderWithName:@"Folder 2"];
347 351
348 // Load the menu for a bookmark. 352 // Load the menu for a bookmark.
349 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL Info")] 353 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL Info")]
350 performAction:grey_tap()]; 354 performAction:grey_tap()];
351 355
352 // Select a first bookmark. 356 // Select a first bookmark.
353 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionSelect)] 357 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionSelect)]
354 performAction:grey_tap()]; 358 performAction:grey_tap()];
355 359
356 // Select a second bookmark. 360 // Select a second bookmark.
357 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL")] 361 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL")]
358 performAction:grey_tap()]; 362 performAction:grey_tap()];
359 363
360 // Choose the move action. 364 // Choose the move action.
361 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Move")] 365 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Move")]
362 performAction:grey_tap()]; 366 performAction:grey_tap()];
363 367
364 // Pick the destination. 368 // Pick the destination.
365 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder 2")] 369 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder 2")]
366 performAction:grey_tap()]; 370 performAction:grey_tap()];
367 371
368 // Wait for undo to show up (there is a 300ms delay for the user to see the 372 // Wait for undo to show up (there is a 300ms delay for the user to see the
369 // change). 373 // change).
370 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Undo")] 374 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Undo")]
371 assertWithMatcher:grey_sufficientlyVisible()]; 375 assertWithMatcher:grey_sufficientlyVisible()];
372 376
373 // Verify that folder 2 has 3 children now, and that they are no longer 377 // Verify that folder 2 has 3 children now, and that they are no longer
374 // visible. 378 // visible.
375 [[self class] assertChildCount:3 ofFolderWithName:@"Folder 2"]; 379 [BookmarksTestCase assertChildCount:3 ofFolderWithName:@"Folder 2"];
376 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL")] 380 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL")]
377 assertWithMatcher:grey_notVisible()]; 381 assertWithMatcher:grey_notVisible()];
378 382
379 // Press undo. 383 // Press undo.
380 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Undo")] 384 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Undo")]
381 performAction:grey_tap()]; 385 performAction:grey_tap()];
382 386
383 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; 387 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
384 388
385 // Verify it's back. 389 // Verify it's back.
386 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL")] 390 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Second URL")]
387 assertWithMatcher:grey_notNil()]; 391 assertWithMatcher:grey_notNil()];
388 392
389 // Verify that folder 2 is back to one child. 393 // Verify that folder 2 is back to one child.
390 [[self class] assertChildCount:1 ofFolderWithName:@"Folder 2"]; 394 [BookmarksTestCase assertChildCount:1 ofFolderWithName:@"Folder 2"];
391 } 395 }
392 396
393 - (void)testLabelUpdatedUponMove { 397 - (void)testLabelUpdatedUponMove {
394 [[self class] setupStandardBookmarks]; 398 [BookmarksTestCase setupStandardBookmarks];
395 [[self class] openMobileBookmarks]; 399 [BookmarksTestCase openMobileBookmarks];
396 400
397 // Load the menu for a bookmark. 401 // Load the menu for a bookmark.
398 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 402 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
399 performAction:grey_tap()]; 403 performAction:grey_tap()];
400 404
401 // Tap on the Edit action. 405 // Tap on the Edit action.
402 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)] 406 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
403 performAction:grey_tap()]; 407 performAction:grey_tap()];
404 408
405 // Tap the Folder button. 409 // Tap the Folder button.
406 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")] 410 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")]
407 performAction:grey_tap()]; 411 performAction:grey_tap()];
408 412
409 // Create a new folder with default name. 413 // Create a new folder with default name.
410 [[self class] addFolderWithName:nil]; 414 [BookmarksTestCase addFolderWithName:nil];
411 415
412 // Verify that the editor is present. 416 // Verify that the editor is present.
413 [[EarlGrey 417 [[EarlGrey
414 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 418 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
415 assertWithMatcher:grey_notNil()]; 419 assertWithMatcher:grey_notNil()];
416 420
417 // Check the new folder label. 421 // Check the new folder label.
418 [[EarlGrey 422 [[EarlGrey
419 selectElementWithMatcher:grey_allOf( 423 selectElementWithMatcher:grey_allOf(
420 grey_accessibilityID(@"Change Folder"), 424 grey_accessibilityID(@"Change Folder"),
421 grey_accessibilityLabel(@"New Folder"), nil)] 425 grey_accessibilityLabel(@"New Folder"), nil)]
422 assertWithMatcher:grey_notNil()]; 426 assertWithMatcher:grey_notNil()];
423 } 427 }
424 428
425 // Test the creation of a bookmark and new folder. 429 // Test the creation of a bookmark and new folder.
426 - (void)testAddBookmarkInNewFolder { 430 - (void)testAddBookmarkInNewFolder {
427 const GURL bookmarkedURL = web::test::HttpServer::MakeUrl( 431 const GURL bookmarkedURL = web::test::HttpServer::MakeUrl(
428 "http://ios/testing/data/http_server_files/pony.html"); 432 "http://ios/testing/data/http_server_files/pony.html");
429 std::string expectedURLContent = bookmarkedURL.GetContent(); 433 std::string expectedURLContent = bookmarkedURL.GetContent();
430 434
431 [ChromeEarlGrey loadURL:bookmarkedURL]; 435 [ChromeEarlGrey loadURL:bookmarkedURL];
432 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 436 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
433 expectedURLContent)] 437 expectedURLContent)]
434 assertWithMatcher:grey_notNil()]; 438 assertWithMatcher:grey_notNil()];
435 439
436 [[self class] starCurrentTab]; 440 [BookmarksTestCase starCurrentTab];
437 441
438 // Verify the snackbar title. 442 // Verify the snackbar title.
439 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bookmarked")] 443 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bookmarked")]
440 assertWithMatcher:grey_notNil()]; 444 assertWithMatcher:grey_notNil()];
441 445
442 // Tap on the snackbar. 446 // Tap on the snackbar.
443 NSString* snackbarLabel = 447 NSString* snackbarLabel =
444 l10n_util::GetNSString(IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON); 448 l10n_util::GetNSString(IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON);
445 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(snackbarLabel)] 449 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(snackbarLabel)]
446 performAction:grey_tap()]; 450 performAction:grey_tap()];
447 451
448 // Verify that the newly-created bookmark is in the BookmarkModel. 452 // Verify that the newly-created bookmark is in the BookmarkModel.
449 [[self class] 453 [BookmarksTestCase
450 assertBookmarksWithTitle:base::SysUTF8ToNSString(expectedURLContent) 454 assertBookmarksWithTitle:base::SysUTF8ToNSString(expectedURLContent)
451 expectedCount:1]; 455 expectedCount:1];
452 456
453 // Verify that the editor is present. 457 // Verify that the editor is present.
454 [[EarlGrey 458 [[EarlGrey
455 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 459 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
456 assertWithMatcher:grey_notNil()]; 460 assertWithMatcher:grey_notNil()];
457 461
458 [[self class] assertFolderName:@"Mobile Bookmarks"]; 462 [BookmarksTestCase assertFolderName:@"Mobile Bookmarks"];
459 463
460 // Tap the Folder button. 464 // Tap the Folder button.
461 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")] 465 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")]
462 performAction:grey_tap()]; 466 performAction:grey_tap()];
463 467
464 // Create a new folder with default name. 468 // Create a new folder with default name.
465 [[self class] addFolderWithName:nil]; 469 [BookmarksTestCase addFolderWithName:nil];
466 470
467 // Verify that the editor is present. 471 // Verify that the editor is present.
468 [[EarlGrey 472 [[EarlGrey
469 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 473 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
470 assertWithMatcher:grey_notNil()]; 474 assertWithMatcher:grey_notNil()];
471 475
472 [[self class] assertFolderExists:@"New Folder"]; 476 [BookmarksTestCase assertFolderExists:@"New Folder"];
473 } 477 }
474 478
475 // Tests that changing a folder's title in edit mode works as expected. 479 // Tests that changing a folder's title in edit mode works as expected.
476 - (void)testChangeFolderTitle { 480 - (void)testChangeFolderTitle {
477 NSString* existingFolderTitle = @"Folder 1"; 481 NSString* existingFolderTitle = @"Folder 1";
478 NSString* newFolderTitle = @"New Folder Title"; 482 NSString* newFolderTitle = @"New Folder Title";
479 483
480 [[self class] setupStandardBookmarks]; 484 [BookmarksTestCase setupStandardBookmarks];
481 [[self class] openMobileBookmarks]; 485 [BookmarksTestCase openMobileBookmarks];
482 [[self class] openEditBookmarkFolderWithFolderTitle:existingFolderTitle]; 486 [BookmarksTestCase openEditBookmarkFolderWithFolderTitle:existingFolderTitle];
483 [[self class] renameBookmarkFolderWithFolderTitle:newFolderTitle]; 487 [BookmarksTestCase renameBookmarkFolderWithFolderTitle:newFolderTitle];
484 [[self class] closeEditBookmarkFolder]; 488 [BookmarksTestCase closeEditBookmarkFolder];
485 489
486 if (IsCompact()) { 490 if (IsCompact()) {
487 // Exit from bookmarks modal. IPad shows bookmarks in tab. 491 // Exit from bookmarks modal. IPad shows bookmarks in tab.
488 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 492 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
489 performAction:grey_tap()]; 493 performAction:grey_tap()];
490 } 494 }
491 495
492 // Verify that the change has been made. 496 // Verify that the change has been made.
493 [[self class] openMobileBookmarks]; 497 [BookmarksTestCase openMobileBookmarks];
494 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(existingFolderTitle)] 498 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(existingFolderTitle)]
495 assertWithMatcher:grey_nil()]; 499 assertWithMatcher:grey_nil()];
496 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(newFolderTitle)] 500 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(newFolderTitle)]
497 assertWithMatcher:grey_notNil()]; 501 assertWithMatcher:grey_notNil()];
498 } 502 }
499 503
500 // Tests that the default folder bookmarks are saved in is updated to the last 504 // Tests that the default folder bookmarks are saved in is updated to the last
501 // used folder. 505 // used folder.
502 - (void)testStickyDefaultFolder { 506 - (void)testStickyDefaultFolder {
503 [[self class] setupStandardBookmarks]; 507 [BookmarksTestCase setupStandardBookmarks];
504 [[self class] openMobileBookmarks]; 508 [BookmarksTestCase openMobileBookmarks];
505 509
506 // Tap on the top-right button. 510 // Tap on the top-right button.
507 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 511 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
508 performAction:grey_tap()]; 512 performAction:grey_tap()];
509 513
510 // Tap the edit action. 514 // Tap the edit action.
511 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)] 515 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
512 performAction:grey_tap()]; 516 performAction:grey_tap()];
513 517
514 // Tap the Folder button. 518 // Tap the Folder button.
515 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")] 519 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")]
516 performAction:grey_tap()]; 520 performAction:grey_tap()];
517 521
518 // Create a new folder. 522 // Create a new folder.
519 [[self class] addFolderWithName:@"Sticky Folder"]; 523 [BookmarksTestCase addFolderWithName:@"Sticky Folder"];
520 524
521 // Verify that the editor is present. 525 // Verify that the editor is present.
522 [[EarlGrey 526 [[EarlGrey
523 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 527 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
524 assertWithMatcher:grey_sufficientlyVisible()]; 528 assertWithMatcher:grey_sufficientlyVisible()];
525 529
526 // Tap the Done button. 530 // Tap the Done button.
527 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 531 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
528 performAction:grey_tap()]; 532 performAction:grey_tap()];
529 [[EarlGrey 533 [[EarlGrey
530 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 534 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
531 assertWithMatcher:grey_notVisible()]; 535 assertWithMatcher:grey_notVisible()];
532 536
533 if (IsCompact()) { 537 if (IsCompact()) {
534 // Dismiss the bookmarks screen. 538 // Dismiss the bookmarks screen.
535 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Exit")] 539 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Exit")]
536 performAction:grey_tap()]; 540 performAction:grey_tap()];
537 } 541 }
538 542
539 // Second, bookmark a page. 543 // Second, bookmark a page.
540 544
541 // Verify that the bookmark that is going to be added is not in the 545 // Verify that the bookmark that is going to be added is not in the
542 // BookmarkModel. 546 // BookmarkModel.
543 const GURL bookmarkedURL = web::test::HttpServer::MakeUrl( 547 const GURL bookmarkedURL = web::test::HttpServer::MakeUrl(
544 "http://ios/testing/data/http_server_files/fullscreen.html"); 548 "http://ios/testing/data/http_server_files/fullscreen.html");
545 NSString* const bookmarkedURLString = 549 NSString* const bookmarkedURLString =
546 base::SysUTF8ToNSString(bookmarkedURL.spec()); 550 base::SysUTF8ToNSString(bookmarkedURL.spec());
547 [[self class] assertBookmarksWithTitle:bookmarkedURLString expectedCount:0]; 551 [BookmarksTestCase assertBookmarksWithTitle:bookmarkedURLString
552 expectedCount:0];
548 // Open the page. 553 // Open the page.
549 std::string expectedURLContent = bookmarkedURL.GetContent(); 554 std::string expectedURLContent = bookmarkedURL.GetContent();
550 [ChromeEarlGrey loadURL:bookmarkedURL]; 555 [ChromeEarlGrey loadURL:bookmarkedURL];
551 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 556 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
552 expectedURLContent)] 557 expectedURLContent)]
553 assertWithMatcher:grey_notNil()]; 558 assertWithMatcher:grey_notNil()];
554 559
555 // Verify that the folder has only one element. 560 // Verify that the folder has only one element.
556 [[self class] assertChildCount:1 ofFolderWithName:@"Sticky Folder"]; 561 [BookmarksTestCase assertChildCount:1 ofFolderWithName:@"Sticky Folder"];
557 562
558 // Bookmark the page. 563 // Bookmark the page.
559 [[self class] starCurrentTab]; 564 [BookmarksTestCase starCurrentTab];
560 565
561 // Verify the snackbar title. 566 // Verify the snackbar title.
562 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel( 567 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
563 @"Bookmarked to Sticky Folder")] 568 @"Bookmarked to Sticky Folder")]
564 assertWithMatcher:grey_sufficientlyVisible()]; 569 assertWithMatcher:grey_sufficientlyVisible()];
565 570
566 // Verify that the newly-created bookmark is in the BookmarkModel. 571 // Verify that the newly-created bookmark is in the BookmarkModel.
567 [[self class] assertBookmarksWithTitle:bookmarkedURLString expectedCount:1]; 572 [BookmarksTestCase assertBookmarksWithTitle:bookmarkedURLString
573 expectedCount:1];
568 574
569 // Verify that the folder has now two elements. 575 // Verify that the folder has now two elements.
570 [[self class] assertChildCount:2 ofFolderWithName:@"Sticky Folder"]; 576 [BookmarksTestCase assertChildCount:2 ofFolderWithName:@"Sticky Folder"];
571 } 577 }
572 578
573 // Tests that changes to the parent folder from the Single Bookmark Controller 579 // Tests that changes to the parent folder from the Single Bookmark Controller
574 // are saved to the bookmark only when saving the results. 580 // are saved to the bookmark only when saving the results.
575 - (void)testMoveDoesSaveOnSave { 581 - (void)testMoveDoesSaveOnSave {
576 [[self class] setupStandardBookmarks]; 582 [BookmarksTestCase setupStandardBookmarks];
577 [[self class] openTopLevelBookmarksFolder]; 583 [BookmarksTestCase openTopLevelBookmarksFolder];
578 584
579 // Tap on the top-right button. 585 // Tap on the top-right button.
580 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 586 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
581 performAction:grey_tap()]; 587 performAction:grey_tap()];
582 588
583 // Tap the edit action. 589 // Tap the edit action.
584 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)] 590 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
585 performAction:grey_tap()]; 591 performAction:grey_tap()];
586 592
587 // Tap the Folder button. 593 // Tap the Folder button.
588 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")] 594 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")]
589 performAction:grey_tap()]; 595 performAction:grey_tap()];
590 596
591 // Create a new folder. 597 // Create a new folder.
592 [[self class] addFolderWithName:nil]; 598 [BookmarksTestCase addFolderWithName:nil];
593 599
594 // Verify that the editor is present. 600 // Verify that the editor is present.
595 [[EarlGrey 601 [[EarlGrey
596 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 602 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
597 assertWithMatcher:grey_sufficientlyVisible()]; 603 assertWithMatcher:grey_sufficientlyVisible()];
598 604
599 // Check that the new folder doesn't contain the bookmark. 605 // Check that the new folder doesn't contain the bookmark.
600 [[self class] assertChildCount:0 ofFolderWithName:@"New Folder"]; 606 [BookmarksTestCase assertChildCount:0 ofFolderWithName:@"New Folder"];
601 607
602 // Tap the Done button. 608 // Tap the Done button.
603 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 609 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
604 performAction:grey_tap()]; 610 performAction:grey_tap()];
605 [[EarlGrey 611 [[EarlGrey
606 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 612 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
607 assertWithMatcher:grey_notVisible()]; 613 assertWithMatcher:grey_notVisible()];
608 614
609 // Check that the new folder contains the bookmark. 615 // Check that the new folder contains the bookmark.
610 [[self class] assertChildCount:1 ofFolderWithName:@"New Folder"]; 616 [BookmarksTestCase assertChildCount:1 ofFolderWithName:@"New Folder"];
611 617
612 // Dismiss the bookmarks screen. 618 // Dismiss the bookmarks screen.
613 if (IsCompact()) { 619 if (IsCompact()) {
614 // Dismiss the bookmarks screen. 620 // Dismiss the bookmarks screen.
615 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Exit")] 621 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Exit")]
616 performAction:grey_tap()]; 622 performAction:grey_tap()];
617 } 623 }
618 624
619 // Check that the new folder still contains the bookmark. 625 // Check that the new folder still contains the bookmark.
620 [[self class] assertChildCount:1 ofFolderWithName:@"New Folder"]; 626 [BookmarksTestCase assertChildCount:1 ofFolderWithName:@"New Folder"];
621 } 627 }
622 628
623 // Test thats editing a single bookmark correctly persists data. 629 // Test thats editing a single bookmark correctly persists data.
624 - (void)testSingleBookmarkEdit { 630 - (void)testSingleBookmarkEdit {
625 [[self class] setupStandardBookmarks]; 631 [BookmarksTestCase setupStandardBookmarks];
626 [[self class] openTopLevelBookmarksFolder]; 632 [BookmarksTestCase openTopLevelBookmarksFolder];
627 633
628 // Load the menu for a bookmark. 634 // Load the menu for a bookmark.
629 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 635 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
630 performAction:grey_tap()]; 636 performAction:grey_tap()];
631 637
632 // Tap the edit action. 638 // Tap the edit action.
633 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)] 639 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
634 performAction:grey_tap()]; 640 performAction:grey_tap()];
635 641
636 // Replace the title field with new text. 642 // Replace the title field with new text.
(...skipping 21 matching lines...) Expand all
658 // Dismiss editor. 664 // Dismiss editor.
659 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 665 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
660 performAction:grey_tap()]; 666 performAction:grey_tap()];
661 [[EarlGrey 667 [[EarlGrey
662 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 668 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
663 assertWithMatcher:grey_notVisible()]; 669 assertWithMatcher:grey_notVisible()];
664 670
665 // Verify that the bookmark was updated. 671 // Verify that the bookmark was updated.
666 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"n5")] 672 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"n5")]
667 assertWithMatcher:grey_sufficientlyVisible()]; 673 assertWithMatcher:grey_sufficientlyVisible()];
668 [[self class] assertExistenceOfBookmarkWithURL:@"http://www.a.fr" name:@"n5"]; 674 [BookmarksTestCase assertExistenceOfBookmarkWithURL:@"http://www.a.fr"
675 name:@"n5"];
669 } 676 }
670 677
671 // Tests that cancelling editing a single bookmark correctly doesn't persist 678 // Tests that cancelling editing a single bookmark correctly doesn't persist
672 // data. 679 // data.
673 - (void)testSingleBookmarkCancelEdit { 680 - (void)testSingleBookmarkCancelEdit {
674 [[self class] setupStandardBookmarks]; 681 [BookmarksTestCase setupStandardBookmarks];
675 [[self class] openTopLevelBookmarksFolder]; 682 [BookmarksTestCase openTopLevelBookmarksFolder];
676 683
677 // Load the menu for a bookmark. 684 // Load the menu for a bookmark.
678 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 685 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
679 performAction:grey_tap()]; 686 performAction:grey_tap()];
680 687
681 // Tap the edit action. 688 // Tap the edit action.
682 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)] 689 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
683 performAction:grey_tap()]; 690 performAction:grey_tap()];
684 691
685 // Replace the title field with new text. 692 // Replace the title field with new text.
(...skipping 21 matching lines...) Expand all
707 // Dismiss editor with Cancel button. 714 // Dismiss editor with Cancel button.
708 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Cancel")] 715 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Cancel")]
709 performAction:grey_tap()]; 716 performAction:grey_tap()];
710 [[EarlGrey 717 [[EarlGrey
711 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] 718 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")]
712 assertWithMatcher:grey_notVisible()]; 719 assertWithMatcher:grey_notVisible()];
713 720
714 // Verify that the bookmark was not updated. 721 // Verify that the bookmark was not updated.
715 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"n5")] 722 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"n5")]
716 assertWithMatcher:grey_notVisible()]; 723 assertWithMatcher:grey_notVisible()];
717 [[self class] assertAbsenceOfBookmarkWithURL:@"http://www.a.fr"]; 724 [BookmarksTestCase assertAbsenceOfBookmarkWithURL:@"http://www.a.fr"];
718 } 725 }
719 726
720 // Tests that long pressing a bookmark selects it and gives access to editing, 727 // Tests that long pressing a bookmark selects it and gives access to editing,
721 // as does the Info menu. 728 // as does the Info menu.
722 - (void)testLongPressBookmark { 729 - (void)testLongPressBookmark {
723 [[self class] setupStandardBookmarks]; 730 [BookmarksTestCase setupStandardBookmarks];
724 [[self class] openTopLevelBookmarksFolder]; 731 [BookmarksTestCase openTopLevelBookmarksFolder];
725 732
726 // Long press the top-right button. 733 // Long press the top-right button.
727 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 734 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
728 performAction:grey_longPress()]; 735 performAction:grey_longPress()];
729 736
730 // Tap the edit button. 737 // Tap the edit button.
731 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Edit_editing_bar")] 738 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Edit_editing_bar")]
732 performAction:grey_tap()]; 739 performAction:grey_tap()];
733 740
734 // Dismiss the editor screen. 741 // Dismiss the editor screen.
735 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 742 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
736 performAction:grey_tap()]; 743 performAction:grey_tap()];
737 744
738 // Tap on the top-right button. 745 // Tap on the top-right button.
739 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 746 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
740 performAction:grey_tap()]; 747 performAction:grey_tap()];
741 748
742 // Tap the edit action. 749 // Tap the edit action.
743 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)] 750 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
744 performAction:grey_tap()]; 751 performAction:grey_tap()];
745 752
746 // Dismiss the editor screen. 753 // Dismiss the editor screen.
747 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 754 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
748 performAction:grey_tap()]; 755 performAction:grey_tap()];
749 } 756 }
750 757
751 // Tests the editing of a folder. 758 // Tests the editing of a folder.
752 - (void)testEditFolder { 759 - (void)testEditFolder {
753 [[self class] setupStandardBookmarks]; 760 [BookmarksTestCase setupStandardBookmarks];
754 [[self class] openBookmarkFolder:@"Folder 1"]; 761 [BookmarksTestCase openBookmarkFolder:@"Folder 1"];
755 762
756 // Tap the Edit button in the navigation bar. 763 // Tap the Edit button in the navigation bar.
757 [[EarlGrey 764 [[EarlGrey
758 selectElementWithMatcher:grey_accessibilityID(@"Edit_navigation_bar")] 765 selectElementWithMatcher:grey_accessibilityID(@"Edit_navigation_bar")]
759 performAction:grey_tap()]; 766 performAction:grey_tap()];
760 767
761 // Change the title. 768 // Change the title.
762 // TODO(crbug.com/644730): Use grey_replaceText instead of 769 // TODO(crbug.com/644730): Use grey_replaceText instead of
763 // grey_clearText/grey_typeText when EarlGrey's issue is fixed: 770 // grey_clearText/grey_typeText when EarlGrey's issue is fixed:
764 // https://github.com/google/EarlGrey/issues/253 771 // https://github.com/google/EarlGrey/issues/253
765 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")] 772 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")]
766 performAction:grey_clearText()]; 773 performAction:grey_clearText()];
767 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")] 774 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")]
768 performAction:grey_typeText(@"Renamed Folder")]; 775 performAction:grey_typeText(@"Renamed Folder")];
769 776
770 // Cancel without saving. 777 // Cancel without saving.
771 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Cancel")] 778 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Cancel")]
772 performAction:grey_tap()]; 779 performAction:grey_tap()];
773 780
774 // Check that Folder 1 still exists at this name, and Renamed Folder doesn't. 781 // Check that Folder 1 still exists at this name, and Renamed Folder doesn't.
775 [[self class] assertFolderExistsWithTitle:@"Folder 1"]; 782 [BookmarksTestCase assertFolderExistsWithTitle:@"Folder 1"];
776 [[self class] assertFolderDoesntExistWithTitle:@"Renamed Folder"]; 783 [BookmarksTestCase assertFolderDoesntExistWithTitle:@"Renamed Folder"];
777 784
778 // Tap the Edit button in the navigation bar. 785 // Tap the Edit button in the navigation bar.
779 [[EarlGrey 786 [[EarlGrey
780 selectElementWithMatcher:grey_accessibilityID(@"Edit_navigation_bar")] 787 selectElementWithMatcher:grey_accessibilityID(@"Edit_navigation_bar")]
781 performAction:grey_tap()]; 788 performAction:grey_tap()];
782 789
783 // Change the title. 790 // Change the title.
784 // TODO(crbug.com/644730): Use grey_replaceText instead of 791 // TODO(crbug.com/644730): Use grey_replaceText instead of
785 // grey_clearText/grey_typeText when EarlGrey's issue is fixed: 792 // grey_clearText/grey_typeText when EarlGrey's issue is fixed:
786 // https://github.com/google/EarlGrey/issues/253 793 // https://github.com/google/EarlGrey/issues/253
787 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")] 794 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")]
788 performAction:grey_clearText()]; 795 performAction:grey_clearText()];
789 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")] 796 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")]
790 performAction:grey_typeText(@"Renamed Folder")]; 797 performAction:grey_typeText(@"Renamed Folder")];
791 798
792 // Save. 799 // Save.
793 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Save")] 800 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Save")]
794 performAction:grey_tap()]; 801 performAction:grey_tap()];
795 802
796 // Check that Folder 1 doesn't exist and Renamed Folder does. 803 // Check that Folder 1 doesn't exist and Renamed Folder does.
797 [[self class] assertFolderDoesntExistWithTitle:@"Folder 1"]; 804 [BookmarksTestCase assertFolderDoesntExistWithTitle:@"Folder 1"];
798 [[self class] assertFolderExistsWithTitle:@"Renamed Folder"]; 805 [BookmarksTestCase assertFolderExistsWithTitle:@"Renamed Folder"];
799 } 806 }
800 807
801 // Tests the deletion of a folder. 808 // Tests the deletion of a folder.
802 - (void)testDeleteFolder { 809 - (void)testDeleteFolder {
803 [[self class] setupStandardBookmarks]; 810 [BookmarksTestCase setupStandardBookmarks];
804 [[self class] openBookmarkFolder:@"Folder 1"]; 811 [BookmarksTestCase openBookmarkFolder:@"Folder 1"];
805 812
806 // Delete the folder. 813 // Delete the folder.
807 [[self class] deleteSelectedFolder]; 814 [BookmarksTestCase deleteSelectedFolder];
808 815
809 // Check that the folder doesn't exist anymore. 816 // Check that the folder doesn't exist anymore.
810 [[self class] assertFolderDoesntExistWithTitle:@"Folder 1"]; 817 [BookmarksTestCase assertFolderDoesntExistWithTitle:@"Folder 1"];
811 } 818 }
812 819
813 // Navigates to a deeply nested folder, deletes it and makes sure the UI is 820 // Navigates to a deeply nested folder, deletes it and makes sure the UI is
814 // consistent. 821 // consistent.
815 - (void)testDeleteCurrentSubfolder { 822 - (void)testDeleteCurrentSubfolder {
816 [[self class] setupStandardBookmarks]; 823 [BookmarksTestCase setupStandardBookmarks];
817 [[self class] openBookmarkFolder:@"Folder 1"]; 824 [BookmarksTestCase openBookmarkFolder:@"Folder 1"];
818 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"Folder 2")] 825 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"Folder 2")]
819 performAction:grey_tap()]; 826 performAction:grey_tap()];
820 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"Folder 3")] 827 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"Folder 3")]
821 performAction:grey_tap()]; 828 performAction:grey_tap()];
822 829
823 // Delete the folder. 830 // Delete the folder.
824 [[self class] deleteSelectedFolder]; 831 [BookmarksTestCase deleteSelectedFolder];
825 832
826 // Folder 3 is now deleted, UI should have moved to Folder 2, and Folder 2 833 // Folder 3 is now deleted, UI should have moved to Folder 2, and Folder 2
827 // should be empty. 834 // should be empty.
828 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Folder 2")] 835 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Folder 2")]
829 assertWithMatcher:grey_sufficientlyVisible()]; 836 assertWithMatcher:grey_sufficientlyVisible()];
830 [[self class] assertChildCount:0 ofFolderWithName:@"Folder 2"]; 837 [BookmarksTestCase assertChildCount:0 ofFolderWithName:@"Folder 2"];
831 [[self class] assertFolderDoesntExistWithTitle:@"Folder 3"]; 838 [BookmarksTestCase assertFolderDoesntExistWithTitle:@"Folder 3"];
832 [[self class] waitForDeletionOfBookmarkWithTitle:@"Folder 3"]; 839 [BookmarksTestCase waitForDeletionOfBookmarkWithTitle:@"Folder 3"];
833 } 840 }
834 841
835 // Navigates to a deeply nested folder, delete its parent programatically. 842 // Navigates to a deeply nested folder, delete its parent programatically.
836 // Verifies that the UI is as expected. 843 // Verifies that the UI is as expected.
837 - (void)testDeleteParentFolder { 844 - (void)testDeleteParentFolder {
838 [[self class] setupStandardBookmarks]; 845 [BookmarksTestCase setupStandardBookmarks];
839 [[self class] openBookmarkFolder:@"Folder 1"]; 846 [BookmarksTestCase openBookmarkFolder:@"Folder 1"];
840 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"Folder 2")] 847 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"Folder 2")]
841 performAction:grey_tap()]; 848 performAction:grey_tap()];
842 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"Folder 3")] 849 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(@"Folder 3")]
843 performAction:grey_tap()]; 850 performAction:grey_tap()];
844 851
845 // Remove the parent programmatically. 852 // Remove the parent programmatically.
846 [[self class] removeBookmarkWithTitle:@"Folder 2"]; 853 [BookmarksTestCase removeBookmarkWithTitle:@"Folder 2"];
847 854
848 // Folder 2 and 3 are now deleted, UI should have moved to Folder1, and 855 // Folder 2 and 3 are now deleted, UI should have moved to Folder1, and
849 // Folder 1 should be empty. 856 // Folder 1 should be empty.
850 [[EarlGrey 857 [[EarlGrey
851 selectElementWithMatcher:grey_allOf( 858 selectElementWithMatcher:grey_allOf(
852 grey_kindOfClass(NSClassFromString( 859 grey_kindOfClass(NSClassFromString(
853 @"BookmarkNavigationBar")), 860 @"BookmarkNavigationBar")),
854 grey_descendant(grey_text(@"Folder 1")), 861 grey_descendant(grey_text(@"Folder 1")),
855 nil)] 862 nil)]
856 assertWithMatcher:grey_sufficientlyVisible()]; 863 assertWithMatcher:grey_sufficientlyVisible()];
857 [[self class] assertChildCount:0 ofFolderWithName:@"Folder 1"]; 864 [BookmarksTestCase assertChildCount:0 ofFolderWithName:@"Folder 1"];
858 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Folder 2")] 865 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Folder 2")]
859 assertWithMatcher:grey_notVisible()]; 866 assertWithMatcher:grey_notVisible()];
860 [[self class] assertFolderDoesntExistWithTitle:@"Folder 2"]; 867 [BookmarksTestCase assertFolderDoesntExistWithTitle:@"Folder 2"];
861 [[self class] assertFolderDoesntExistWithTitle:@"Folder 3"]; 868 [BookmarksTestCase assertFolderDoesntExistWithTitle:@"Folder 3"];
862 869
863 // Check that the selected folder in the menu is Folder 1. 870 // Check that the selected folder in the menu is Folder 1.
864 if (IsCompact()) { 871 if (IsCompact()) {
865 // Opens the bookmark manager sidebar on handsets. 872 // Opens the bookmark manager sidebar on handsets.
866 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Menu")] 873 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Menu")]
867 performAction:grey_tap()]; 874 performAction:grey_tap()];
868 } 875 }
869 [[EarlGrey 876 [[EarlGrey
870 selectElementWithMatcher:grey_allOf( 877 selectElementWithMatcher:grey_allOf(
871 grey_kindOfClass( 878 grey_kindOfClass(
872 NSClassFromString(@"BookmarkMenuCell")), 879 NSClassFromString(@"BookmarkMenuCell")),
873 grey_descendant(grey_text(@"Folder 1")), 880 grey_descendant(grey_text(@"Folder 1")),
874 nil)] 881 nil)]
875 assertWithMatcher:grey_sufficientlyVisible()]; 882 assertWithMatcher:grey_sufficientlyVisible()];
876 } 883 }
877 884
878 // Tests that the menu button changes to a back button as expected when browsing 885 // Tests that the menu button changes to a back button as expected when browsing
879 // nested folders. 886 // nested folders.
880 - (void)testBrowseNestedFolders { 887 - (void)testBrowseNestedFolders {
881 [[self class] setupStandardBookmarks]; 888 [BookmarksTestCase setupStandardBookmarks];
882 [[self class] openMobileBookmarks]; 889 [BookmarksTestCase openMobileBookmarks];
883 890
884 // Navigate down the nested folders. 891 // Navigate down the nested folders.
885 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder 1")] 892 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder 1")]
886 performAction:grey_tap()]; 893 performAction:grey_tap()];
887 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder 2")] 894 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder 2")]
888 performAction:grey_tap()]; 895 performAction:grey_tap()];
889 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder 3")] 896 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder 3")]
890 performAction:grey_tap()]; 897 performAction:grey_tap()];
891 898
892 // Verify the back button is visible to be able to go back to parent. 899 // Verify the back button is visible to be able to go back to parent.
(...skipping 18 matching lines...) Expand all
911 918
912 if (IsCompact()) { 919 if (IsCompact()) {
913 // Verify menu button reappears. 920 // Verify menu button reappears.
914 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Menu")] 921 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Menu")]
915 assertWithMatcher:grey_sufficientlyVisible()]; 922 assertWithMatcher:grey_sufficientlyVisible()];
916 } 923 }
917 } 924 }
918 925
919 // Tests moving a bookmark into a new folder created in the moving process. 926 // Tests moving a bookmark into a new folder created in the moving process.
920 - (void)testCreateNewFolderWhileMovingBookmark { 927 - (void)testCreateNewFolderWhileMovingBookmark {
921 [[self class] setupStandardBookmarks]; 928 [BookmarksTestCase setupStandardBookmarks];
922 [[self class] openMobileBookmarks]; 929 [BookmarksTestCase openMobileBookmarks];
923 930
924 // Tap the info disclosure indicator for the bookmark we want to move. 931 // Tap the info disclosure indicator for the bookmark we want to move.
925 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] 932 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")]
926 performAction:grey_tap()]; 933 performAction:grey_tap()];
927 934
928 // Choose to move the bookmark in the context menu. 935 // Choose to move the bookmark in the context menu.
929 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionMove)] 936 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionMove)]
930 performAction:grey_tap()]; 937 performAction:grey_tap()];
931 938
932 // Choose to move the bookmark into a new folder. 939 // Choose to move the bookmark into a new folder.
933 [[EarlGrey 940 [[EarlGrey
934 selectElementWithMatcher:grey_accessibilityID(@"Create New Folder")] 941 selectElementWithMatcher:grey_accessibilityID(@"Create New Folder")]
935 performAction:grey_tap()]; 942 performAction:grey_tap()];
936 943
937 // Enter custom new folder name. 944 // Enter custom new folder name.
938 [[self class] renameBookmarkFolderWithFolderTitle:@"Title For New Folder"]; 945 [BookmarksTestCase
946 renameBookmarkFolderWithFolderTitle:@"Title For New Folder"];
939 947
940 // Verify current parent folder (Change Folder) is Bookmarks folder. 948 // Verify current parent folder (Change Folder) is Bookmarks folder.
941 [[EarlGrey 949 [[EarlGrey
942 selectElementWithMatcher:grey_allOf( 950 selectElementWithMatcher:grey_allOf(
943 grey_accessibilityID(@"Change Folder"), 951 grey_accessibilityID(@"Change Folder"),
944 grey_accessibilityLabel(@"Mobile Bookmarks"), 952 grey_accessibilityLabel(@"Mobile Bookmarks"),
945 nil)] 953 nil)]
946 assertWithMatcher:grey_sufficientlyVisible()]; 954 assertWithMatcher:grey_sufficientlyVisible()];
947 955
948 // Choose new parent folder (Change Folder). 956 // Choose new parent folder (Change Folder).
949 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")] 957 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Change Folder")]
950 performAction:grey_tap()]; 958 performAction:grey_tap()];
951 959
952 // Verify folder picker UI is displayed. 960 // Verify folder picker UI is displayed.
953 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Picker")] 961 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Picker")]
954 assertWithMatcher:grey_sufficientlyVisible()]; 962 assertWithMatcher:grey_sufficientlyVisible()];
955 963
956 // Verify Folder 2 only has one item. 964 // Verify Folder 2 only has one item.
957 [[self class] assertChildCount:1 ofFolderWithName:@"Folder 2"]; 965 [BookmarksTestCase assertChildCount:1 ofFolderWithName:@"Folder 2"];
958 966
959 // Select Folder 2 as new Change Folder. 967 // Select Folder 2 as new Change Folder.
960 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder 2")] 968 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder 2")]
961 performAction:grey_tap()]; 969 performAction:grey_tap()];
962 970
963 // Verify folder picker is dismissed and folder creator is now visible. 971 // Verify folder picker is dismissed and folder creator is now visible.
964 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Creator")] 972 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Creator")]
965 assertWithMatcher:grey_sufficientlyVisible()]; 973 assertWithMatcher:grey_sufficientlyVisible()];
966 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Picker")] 974 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Picker")]
967 assertWithMatcher:grey_notVisible()]; 975 assertWithMatcher:grey_notVisible()];
(...skipping 11 matching lines...) Expand all
979 987
980 // Verify all folder flow UI is now closed. 988 // Verify all folder flow UI is now closed.
981 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Creator")] 989 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Creator")]
982 assertWithMatcher:grey_notVisible()]; 990 assertWithMatcher:grey_notVisible()];
983 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Picker")] 991 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Picker")]
984 assertWithMatcher:grey_notVisible()]; 992 assertWithMatcher:grey_notVisible()];
985 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Editor")] 993 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Editor")]
986 assertWithMatcher:grey_notVisible()]; 994 assertWithMatcher:grey_notVisible()];
987 995
988 // Verify new folder has been created under Folder 2. 996 // Verify new folder has been created under Folder 2.
989 [[self class] assertChildCount:2 ofFolderWithName:@"Folder 2"]; 997 [BookmarksTestCase assertChildCount:2 ofFolderWithName:@"Folder 2"];
990 998
991 // Verify new folder has one bookmark. 999 // Verify new folder has one bookmark.
992 [[self class] assertChildCount:1 ofFolderWithName:@"Title For New Folder"]; 1000 [BookmarksTestCase assertChildCount:1
1001 ofFolderWithName:@"Title For New Folder"];
993 } 1002 }
994 1003
995 // Navigates to a deeply nested folder, deletes its root ancestor and checks 1004 // Navigates to a deeply nested folder, deletes its root ancestor and checks
996 // that the UI is on the top level folder. 1005 // that the UI is on the top level folder.
997 - (void)testDeleteRootFolder { 1006 - (void)testDeleteRootFolder {
998 [[self class] setupStandardBookmarks]; 1007 [BookmarksTestCase setupStandardBookmarks];
999 [[self class] openBookmarkFolder:@"Folder 1"]; 1008 [BookmarksTestCase openBookmarkFolder:@"Folder 1"];
1000 [[EarlGrey selectElementWithMatcher:grey_text(@"Folder 2")] 1009 [[EarlGrey selectElementWithMatcher:grey_text(@"Folder 2")]
1001 performAction:grey_tap()]; 1010 performAction:grey_tap()];
1002 [[EarlGrey selectElementWithMatcher:grey_text(@"Folder 3")] 1011 [[EarlGrey selectElementWithMatcher:grey_text(@"Folder 3")]
1003 performAction:grey_tap()]; 1012 performAction:grey_tap()];
1004 1013
1005 [[self class] removeBookmarkWithTitle:@"Folder 1"]; 1014 [BookmarksTestCase removeBookmarkWithTitle:@"Folder 1"];
1006 1015
1007 NSString* rootFolderTitle = nil; 1016 NSString* rootFolderTitle = nil;
1008 rootFolderTitle = @"Mobile Bookmarks"; 1017 rootFolderTitle = @"Mobile Bookmarks";
1009 1018
1010 // Folder 2 and 3 are now deleted, UI should have moved to top level folder. 1019 // Folder 2 and 3 are now deleted, UI should have moved to top level folder.
1011 [[EarlGrey 1020 [[EarlGrey
1012 selectElementWithMatcher:grey_allOf( 1021 selectElementWithMatcher:grey_allOf(
1013 grey_kindOfClass(NSClassFromString( 1022 grey_kindOfClass(NSClassFromString(
1014 @"BookmarkNavigationBar")), 1023 @"BookmarkNavigationBar")),
1015 grey_descendant(grey_text(rootFolderTitle)), 1024 grey_descendant(grey_text(rootFolderTitle)),
(...skipping 26 matching lines...) Expand all
1042 } 1051 }
1043 1052
1044 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Folder 1")] 1053 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Folder 1")]
1045 assertWithMatcher:grey_notVisible()]; 1054 assertWithMatcher:grey_notVisible()];
1046 } 1055 }
1047 1056
1048 // Tests that keyboard commands are registered when a bookmark is added with the 1057 // Tests that keyboard commands are registered when a bookmark is added with the
1049 // new bookmark UI as it shows only a snackbar. 1058 // new bookmark UI as it shows only a snackbar.
1050 - (void)testKeyboardCommandsRegistered_AddBookmark { 1059 - (void)testKeyboardCommandsRegistered_AddBookmark {
1051 // Add the bookmark. 1060 // Add the bookmark.
1052 [[self class] starCurrentTab]; 1061 [BookmarksTestCase starCurrentTab];
1053 GREYAssertTrue(chrome_test_util::GetRegisteredKeyCommandsCount() > 0, 1062 GREYAssertTrue(chrome_test_util::GetRegisteredKeyCommandsCount() > 0,
1054 @"Some keyboard commands are registered."); 1063 @"Some keyboard commands are registered.");
1055 } 1064 }
1056 1065
1057 // Tests that keyboard commands are not registered when a bookmark is edited, as 1066 // Tests that keyboard commands are not registered when a bookmark is edited, as
1058 // the edit screen is presented modally. 1067 // the edit screen is presented modally.
1059 - (void)testKeyboardCommandsNotRegistered_EditBookmark { 1068 - (void)testKeyboardCommandsNotRegistered_EditBookmark {
1060 [[self class] setupStandardBookmarks]; 1069 [BookmarksTestCase setupStandardBookmarks];
1061 [[self class] openMobileBookmarks]; 1070 [BookmarksTestCase openMobileBookmarks];
1062 1071
1063 // Go to a bookmarked page. Tap on one of the standard bookmark. 1072 // Go to a bookmarked page. Tap on one of the standard bookmark.
1064 [[EarlGrey selectElementWithMatcher:grey_text(@"Second URL")] 1073 [[EarlGrey selectElementWithMatcher:grey_text(@"Second URL")]
1065 performAction:grey_tap()]; 1074 performAction:grey_tap()];
1066 1075
1067 // Edit the bookmark. 1076 // Edit the bookmark.
1068 if (!IsCompact()) { 1077 if (!IsCompact()) {
1069 [[EarlGrey selectElementWithMatcher:StarButton()] performAction:grey_tap()]; 1078 [[EarlGrey selectElementWithMatcher:StarButton()] performAction:grey_tap()];
1070 } else { 1079 } else {
1071 [ChromeEarlGreyUI openToolsMenu]; 1080 [ChromeEarlGreyUI openToolsMenu];
1072 [[EarlGrey selectElementWithMatcher:LitStarButtoniPhone()] 1081 [[EarlGrey selectElementWithMatcher:LitStarButtoniPhone()]
1073 performAction:grey_tap()]; 1082 performAction:grey_tap()];
1074 } 1083 }
1075 GREYAssertTrue(chrome_test_util::GetRegisteredKeyCommandsCount() == 0, 1084 GREYAssertTrue(chrome_test_util::GetRegisteredKeyCommandsCount() == 0,
1076 @"No keyboard commands are registered."); 1085 @"No keyboard commands are registered.");
1077 } 1086 }
1078 1087
1079 // Tests that tapping No thanks on the promo make it disappear. 1088 // Tests that tapping No thanks on the promo make it disappear.
1080 - (void)testPromoNoThanksMakeItDisappear { 1089 - (void)testPromoNoThanksMakeItDisappear {
1081 [[self class] setupStandardBookmarks]; 1090 [BookmarksTestCase setupStandardBookmarks];
1082 [[self class] openTopLevelBookmarksFolder]; 1091 [BookmarksTestCase openTopLevelBookmarksFolder];
1083 1092
1084 // We are going to set the PromoAlreadySeen preference. Set a teardown handler 1093 // We are going to set the PromoAlreadySeen preference. Set a teardown handler
1085 // to reset it. 1094 // to reset it.
1086 [self setTearDownHandler:^{ 1095 [self setTearDownHandler:^{
1087 [[self class] setPromoAlreadySeen:NO]; 1096 [BookmarksTestCase setPromoAlreadySeen:NO];
1088 }]; 1097 }];
1089 // Check that promo is visible. 1098 // Check that promo is visible.
1090 [[self class] verifyPromoAlreadySeen:NO]; 1099 [BookmarksTestCase verifyPromoAlreadySeen:NO];
1091 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"promo_view")] 1100 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"promo_view")]
1092 assertWithMatcher:grey_notNil()]; 1101 assertWithMatcher:grey_notNil()];
1093 1102
1094 // Tap the dismiss button. 1103 // Tap the dismiss button.
1095 [[EarlGrey 1104 [[EarlGrey
1096 selectElementWithMatcher:grey_accessibilityID(@"promo_no_thanks_button")] 1105 selectElementWithMatcher:grey_accessibilityID(@"promo_no_thanks_button")]
1097 performAction:grey_tap()]; 1106 performAction:grey_tap()];
1098 1107
1099 // Wait until promo is gone. 1108 // Wait until promo is gone.
1100 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"promo_view")] 1109 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"promo_view")]
1101 assertWithMatcher:grey_notVisible()]; 1110 assertWithMatcher:grey_notVisible()];
1102 1111
1103 // Check that the promo already seen state is updated. 1112 // Check that the promo already seen state is updated.
1104 [[self class] verifyPromoAlreadySeen:YES]; 1113 [BookmarksTestCase verifyPromoAlreadySeen:YES];
1105 } 1114 }
1106 1115
1107 // Tests that tapping Sign in on the promo make the Sign in sheet appear and 1116 // Tests that tapping Sign in on the promo make the Sign in sheet appear and
1108 // the promo still appears after dismissing the Sign in sheet. 1117 // the promo still appears after dismissing the Sign in sheet.
1109 - (void)testUIPromoSignIn { 1118 - (void)testUIPromoSignIn {
1110 [[self class] setupStandardBookmarks]; 1119 [BookmarksTestCase setupStandardBookmarks];
1111 [[self class] openTopLevelBookmarksFolder]; 1120 [BookmarksTestCase openTopLevelBookmarksFolder];
1112 // Set up a fake identity. 1121 // Set up a fake identity.
1113 ChromeIdentity* identity = 1122 ChromeIdentity* identity =
1114 [FakeChromeIdentity identityWithEmail:@"fakefoo@egmail.com" 1123 [FakeChromeIdentity identityWithEmail:@"fakefoo@egmail.com"
1115 gaiaID:@"fakefoopassword" 1124 gaiaID:@"fakefoopassword"
1116 name:@"Fake Foo"]; 1125 name:@"Fake Foo"];
1117 ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity( 1126 ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
1118 identity); 1127 identity);
1119 1128
1120 // Check that promo is visible. 1129 // Check that promo is visible.
1121 [[self class] verifyPromoAlreadySeen:NO]; 1130 [BookmarksTestCase verifyPromoAlreadySeen:NO];
1122 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"promo_view")] 1131 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"promo_view")]
1123 assertWithMatcher:grey_notNil()]; 1132 assertWithMatcher:grey_notNil()];
1124 1133
1125 // Tap the Sign in button. 1134 // Tap the Sign in button.
1126 [[EarlGrey 1135 [[EarlGrey
1127 selectElementWithMatcher:grey_accessibilityID(@"promo_sign_in_button")] 1136 selectElementWithMatcher:grey_accessibilityID(@"promo_sign_in_button")]
1128 performAction:grey_tap()]; 1137 performAction:grey_tap()];
1129 1138
1130 // Tap the CANCEL button. 1139 // Tap the CANCEL button.
1131 [[EarlGrey selectElementWithMatcher: 1140 [[EarlGrey selectElementWithMatcher:
1132 grey_buttonTitle([l10n_util::GetNSString( 1141 grey_buttonTitle([l10n_util::GetNSString(
1133 IDS_IOS_ACCOUNT_CONSISTENCY_SETUP_SKIP_BUTTON) 1142 IDS_IOS_ACCOUNT_CONSISTENCY_SETUP_SKIP_BUTTON)
1134 uppercaseString])] performAction:grey_tap()]; 1143 uppercaseString])] performAction:grey_tap()];
1135 1144
1136 // Check that the bookmarks UI reappeared and the cell is still here. 1145 // Check that the bookmarks UI reappeared and the cell is still here.
1137 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"promo_view")] 1146 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"promo_view")]
1138 assertWithMatcher:grey_notNil()]; 1147 assertWithMatcher:grey_notNil()];
1139 1148
1140 [[self class] verifyPromoAlreadySeen:NO]; 1149 [BookmarksTestCase verifyPromoAlreadySeen:NO];
1141 } 1150 }
1142 1151
1143 // Tests that all elements on the bookmarks landing page are accessible. 1152 // Tests that all elements on the bookmarks landing page are accessible.
1144 - (void)testAccessibilityOnBookmarksLandingPage { 1153 - (void)testAccessibilityOnBookmarksLandingPage {
1145 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark]; 1154 [BookmarksTestCase openMobileBookmarksPrepopulatedWithOneBookmark];
1146 1155
1147 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 1156 chrome_test_util::VerifyAccessibilityForCurrentScreen();
1148 if (IsCompact()) { 1157 if (IsCompact()) {
1149 // Exit from bookmarks modal. IPad shows bookmarks in tab. 1158 // Exit from bookmarks modal. IPad shows bookmarks in tab.
1150 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 1159 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1151 performAction:grey_tap()]; 1160 performAction:grey_tap()];
1152 } 1161 }
1153 } 1162 }
1154 1163
1155 // Tests that all elements on the bookmarks Edit page are accessible. 1164 // Tests that all elements on the bookmarks Edit page are accessible.
1156 - (void)testAccessibilityOnBookmarksEditPage { 1165 - (void)testAccessibilityOnBookmarksEditPage {
1157 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark]; 1166 [BookmarksTestCase openMobileBookmarksPrepopulatedWithOneBookmark];
1158 1167
1159 // Load the menu for a bookmark. 1168 // Load the menu for a bookmark.
1160 [[EarlGrey selectElementWithMatcher:MoreMenuButton()] 1169 [[EarlGrey selectElementWithMatcher:MoreMenuButton()]
1161 performAction:grey_tap()]; 1170 performAction:grey_tap()];
1162 1171
1163 // Tap the edit action. 1172 // Tap the edit action.
1164 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)] 1173 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionEdit)]
1165 performAction:grey_tap()]; 1174 performAction:grey_tap()];
1166 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 1175 chrome_test_util::VerifyAccessibilityForCurrentScreen();
1167 if (IsCompact()) { 1176 if (IsCompact()) {
1168 // Exit from bookmarks modal. IPad shows bookmarks in tab. 1177 // Exit from bookmarks modal. IPad shows bookmarks in tab.
1169 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 1178 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1170 performAction:grey_tap()]; 1179 performAction:grey_tap()];
1171 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 1180 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1172 performAction:grey_tap()]; 1181 performAction:grey_tap()];
1173 } 1182 }
1174 } 1183 }
1175 1184
1176 // Tests that all elements on the bookmarks Move page are accessible. 1185 // Tests that all elements on the bookmarks Move page are accessible.
1177 - (void)testAccessibilityOnBookmarksMovePage { 1186 - (void)testAccessibilityOnBookmarksMovePage {
1178 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark]; 1187 [BookmarksTestCase openMobileBookmarksPrepopulatedWithOneBookmark];
1179 1188
1180 // Load the menu for a bookmark. 1189 // Load the menu for a bookmark.
1181 [[EarlGrey selectElementWithMatcher:MoreMenuButton()] 1190 [[EarlGrey selectElementWithMatcher:MoreMenuButton()]
1182 performAction:grey_tap()]; 1191 performAction:grey_tap()];
1183 1192
1184 // Tap the Move action. 1193 // Tap the Move action.
1185 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionMove)] 1194 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionMove)]
1186 performAction:grey_tap()]; 1195 performAction:grey_tap()];
1187 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 1196 chrome_test_util::VerifyAccessibilityForCurrentScreen();
1188 if (IsCompact()) { 1197 if (IsCompact()) {
1189 // Exit from bookmarks modal. IPad shows bookmarks in tab. 1198 // Exit from bookmarks modal. IPad shows bookmarks in tab.
1190 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 1199 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1191 performAction:grey_tap()]; 1200 performAction:grey_tap()];
1192 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 1201 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1193 performAction:grey_tap()]; 1202 performAction:grey_tap()];
1194 } 1203 }
1195 } 1204 }
1196 1205
1197 // Tests that all elements on the bookmarks Move to New Folder page are 1206 // Tests that all elements on the bookmarks Move to New Folder page are
1198 // accessible. 1207 // accessible.
1199 - (void)testAccessibilityOnBookmarksMoveToNewFolderPage { 1208 - (void)testAccessibilityOnBookmarksMoveToNewFolderPage {
1200 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark]; 1209 [BookmarksTestCase openMobileBookmarksPrepopulatedWithOneBookmark];
1201 1210
1202 // Load the menu for a bookmark. 1211 // Load the menu for a bookmark.
1203 [[EarlGrey selectElementWithMatcher:MoreMenuButton()] 1212 [[EarlGrey selectElementWithMatcher:MoreMenuButton()]
1204 performAction:grey_tap()]; 1213 performAction:grey_tap()];
1205 1214
1206 // Tap the Move action. 1215 // Tap the Move action.
1207 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionMove)] 1216 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionMove)]
1208 performAction:grey_tap()]; 1217 performAction:grey_tap()];
1209 // Tap on "Create New Folder." 1218 // Tap on "Create New Folder."
1210 [[EarlGrey 1219 [[EarlGrey
1211 selectElementWithMatcher:grey_accessibilityID(@"Create New Folder")] 1220 selectElementWithMatcher:grey_accessibilityID(@"Create New Folder")]
1212 performAction:grey_tap()]; 1221 performAction:grey_tap()];
1213 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 1222 chrome_test_util::VerifyAccessibilityForCurrentScreen();
1214 if (IsCompact()) { 1223 if (IsCompact()) {
1215 // Exit from bookmarks modal. IPad shows bookmarks in tab. 1224 // Exit from bookmarks modal. IPad shows bookmarks in tab.
1216 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 1225 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1217 performAction:grey_tap()]; 1226 performAction:grey_tap()];
1218 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 1227 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1219 performAction:grey_tap()]; 1228 performAction:grey_tap()];
1220 } 1229 }
1221 } 1230 }
1222 1231
1223 // Tests that all elements on bookmarks Delete and Undo are accessible. 1232 // Tests that all elements on bookmarks Delete and Undo are accessible.
1224 - (void)testAccessibilityOnBookmarksDeleteUndo { 1233 - (void)testAccessibilityOnBookmarksDeleteUndo {
1225 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark]; 1234 [BookmarksTestCase openMobileBookmarksPrepopulatedWithOneBookmark];
1226 1235
1227 // Load the menu for a bookmark. 1236 // Load the menu for a bookmark.
1228 [[EarlGrey selectElementWithMatcher:MoreMenuButton()] 1237 [[EarlGrey selectElementWithMatcher:MoreMenuButton()]
1229 performAction:grey_tap()]; 1238 performAction:grey_tap()];
1230 1239
1231 // Tap the Delete action. 1240 // Tap the Delete action.
1232 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionDelete)] 1241 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionDelete)]
1233 performAction:grey_tap()]; 1242 performAction:grey_tap()];
1234 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 1243 chrome_test_util::VerifyAccessibilityForCurrentScreen();
1235 if (IsCompact()) { 1244 if (IsCompact()) {
1236 // Exit from bookmarks modal. IPad shows bookmarks in tab. 1245 // Exit from bookmarks modal. IPad shows bookmarks in tab.
1237 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()] 1246 [[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
1238 performAction:grey_tap()]; 1247 performAction:grey_tap()];
1239 } 1248 }
1240 } 1249 }
1241 1250
1242 // Tests that all elements on the bookmarks Select page are accessible. 1251 // Tests that all elements on the bookmarks Select page are accessible.
1243 - (void)testAccessibilityOnBookmarksSelect { 1252 - (void)testAccessibilityOnBookmarksSelect {
1244 [[self class] openMobileBookmarksPrepopulatedWithOneBookmark]; 1253 [BookmarksTestCase openMobileBookmarksPrepopulatedWithOneBookmark];
1245 1254
1246 // Load the menu for a bookmark. 1255 // Load the menu for a bookmark.
1247 [[EarlGrey selectElementWithMatcher:MoreMenuButton()] 1256 [[EarlGrey selectElementWithMatcher:MoreMenuButton()]
1248 performAction:grey_tap()]; 1257 performAction:grey_tap()];
1249 1258
1250 // Tap the Select action. 1259 // Tap the Select action.
1251 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionSelect)] 1260 [[EarlGrey selectElementWithMatcher:ActionSheet(ActionSelect)]
1252 performAction:grey_tap()]; 1261 performAction:grey_tap()];
1253 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 1262 chrome_test_util::VerifyAccessibilityForCurrentScreen();
1254 // Dismiss selector with Cancel button. 1263 // Dismiss selector with Cancel button.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 [BookmarksTestCase openBookmarkFolder:@"Mobile Bookmarks"]; 1310 [BookmarksTestCase openBookmarkFolder:@"Mobile Bookmarks"];
1302 } 1311 }
1303 1312
1304 // Adds a bookmark, then navigates to the bookmark manager UI, and 1313 // Adds a bookmark, then navigates to the bookmark manager UI, and
1305 // selects MobileBookmarks. 1314 // selects MobileBookmarks.
1306 + (void)openMobileBookmarksPrepopulatedWithOneBookmark { 1315 + (void)openMobileBookmarksPrepopulatedWithOneBookmark {
1307 const GURL bookmarkURL = web::test::HttpServer::MakeUrl( 1316 const GURL bookmarkURL = web::test::HttpServer::MakeUrl(
1308 "http://ios/testing/data/http_server_files/destination.html"); 1317 "http://ios/testing/data/http_server_files/destination.html");
1309 NSString* bookmarkTitle = @"smokeTapBookmark"; 1318 NSString* bookmarkTitle = @"smokeTapBookmark";
1310 // Load a bookmark into the bookmark model. 1319 // Load a bookmark into the bookmark model.
1311 [[self class] addBookmark:bookmarkURL withTitle:bookmarkTitle]; 1320 [BookmarksTestCase addBookmark:bookmarkURL withTitle:bookmarkTitle];
1312 1321
1313 // Open the UI for Bookmarks. 1322 // Open the UI for Bookmarks.
1314 [[self class] openMobileBookmarks]; 1323 [BookmarksTestCase openMobileBookmarks];
1315 1324
1316 // Verify bookmark is visible. 1325 // Verify bookmark is visible.
1317 [[EarlGrey 1326 [[EarlGrey
1318 selectElementWithMatcher:ButtonWithAccessibilityLabel(bookmarkTitle)] 1327 selectElementWithMatcher:ButtonWithAccessibilityLabel(bookmarkTitle)]
1319 assertWithMatcher:grey_sufficientlyVisible() 1328 assertWithMatcher:grey_sufficientlyVisible()
1320 error:nil]; 1329 error:nil];
1321 } 1330 }
1322 1331
1323 // Navigates to the edit folder UI for |folderTitle|. 1332 // Navigates to the edit folder UI for |folderTitle|.
1324 + (void)openEditBookmarkFolderWithFolderTitle:(NSString*)folderTitle { 1333 + (void)openEditBookmarkFolderWithFolderTitle:(NSString*)folderTitle {
(...skipping 24 matching lines...) Expand all
1349 // Type in the new title and use '\n' to dismiss the keyboard. 1358 // Type in the new title and use '\n' to dismiss the keyboard.
1350 NSString* folderTitleWithNewLine = 1359 NSString* folderTitleWithNewLine =
1351 [NSString stringWithFormat:@"%@\n", folderTitle]; 1360 [NSString stringWithFormat:@"%@\n", folderTitle];
1352 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(titleIdentifier)] 1361 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(titleIdentifier)]
1353 performAction:grey_typeText(folderTitleWithNewLine)]; 1362 performAction:grey_typeText(folderTitleWithNewLine)];
1354 } 1363 }
1355 1364
1356 // Tap on the star to bookmark a page, then edit the bookmark to change the 1365 // Tap on the star to bookmark a page, then edit the bookmark to change the
1357 // title to |title|. 1366 // title to |title|.
1358 + (void)bookmarkCurrentTabWithTitle:(NSString*)title { 1367 + (void)bookmarkCurrentTabWithTitle:(NSString*)title {
1359 [[self class] waitForBookmarkModelLoaded:YES]; 1368 [BookmarksTestCase waitForBookmarkModelLoaded:YES];
1360 // Add the bookmark from the UI. 1369 // Add the bookmark from the UI.
1361 [[self class] starCurrentTab]; 1370 [BookmarksTestCase starCurrentTab];
1362 1371
1363 // Set the bookmark name. 1372 // Set the bookmark name.
1364 [[EarlGrey selectElementWithMatcher:EditBookmarkButton()] 1373 [[EarlGrey selectElementWithMatcher:EditBookmarkButton()]
1365 performAction:grey_tap()]; 1374 performAction:grey_tap()];
1366 NSString* titleIdentifier = @"Title Field_textField"; 1375 NSString* titleIdentifier = @"Title Field_textField";
1367 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(titleIdentifier)] 1376 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(titleIdentifier)]
1368 performAction:grey_tap()]; 1377 performAction:grey_tap()];
1369 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Clear text")] 1378 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Clear text")]
1370 performAction:grey_tap()]; 1379 performAction:grey_tap()];
1371 1380
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 GREYAssert(folder, @"No folder named %@", name); 1475 GREYAssert(folder, @"No folder named %@", name);
1467 GREYAssertEqual( 1476 GREYAssertEqual(
1468 folder->child_count(), count, 1477 folder->child_count(), count,
1469 @"Unexpected number of children in folder '%@': %d instead of %d", name, 1478 @"Unexpected number of children in folder '%@': %d instead of %d", name,
1470 folder->child_count(), count); 1479 folder->child_count(), count);
1471 } 1480 }
1472 1481
1473 // Adds a bookmark with the given |url| and |title| into the Mobile Bookmarks 1482 // Adds a bookmark with the given |url| and |title| into the Mobile Bookmarks
1474 // folder. 1483 // folder.
1475 + (void)addBookmark:(const GURL)url withTitle:(NSString*)title { 1484 + (void)addBookmark:(const GURL)url withTitle:(NSString*)title {
1476 [[self class] waitForBookmarkModelLoaded:YES]; 1485 [BookmarksTestCase waitForBookmarkModelLoaded:YES];
1477 bookmarks::BookmarkModel* bookmark_model = 1486 bookmarks::BookmarkModel* bookmark_model =
1478 ios::BookmarkModelFactory::GetForBrowserState( 1487 ios::BookmarkModelFactory::GetForBrowserState(
1479 chrome_test_util::GetOriginalBrowserState()); 1488 chrome_test_util::GetOriginalBrowserState());
1480 bookmark_model->AddURL(bookmark_model->mobile_node(), 0, 1489 bookmark_model->AddURL(bookmark_model->mobile_node(), 0,
1481 base::SysNSStringToUTF16(title), url); 1490 base::SysNSStringToUTF16(title), url);
1482 } 1491 }
1483 1492
1484 // Creates a new folder starting from the folder picker. 1493 // Creates a new folder starting from the folder picker.
1485 // Passing a |name| of 0 length will use the default value. 1494 // Passing a |name| of 0 length will use the default value.
1486 + (void)addFolderWithName:(NSString*)name { 1495 + (void)addFolderWithName:(NSString*)name {
(...skipping 23 matching lines...) Expand all
1510 performAction:grey_typeText(name)]; 1519 performAction:grey_typeText(name)];
1511 } 1520 }
1512 1521
1513 // Tap the Save button. 1522 // Tap the Save button.
1514 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Save")] 1523 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Save")]
1515 performAction:grey_tap()]; 1524 performAction:grey_tap()];
1516 } 1525 }
1517 1526
1518 // Loads a set of default bookmarks in the model for the tests to use. 1527 // Loads a set of default bookmarks in the model for the tests to use.
1519 + (void)setupStandardBookmarks { 1528 + (void)setupStandardBookmarks {
1520 [[self class] waitForBookmarkModelLoaded:YES]; 1529 [BookmarksTestCase waitForBookmarkModelLoaded:YES];
1521 1530
1522 bookmarks::BookmarkModel* bookmark_model = 1531 bookmarks::BookmarkModel* bookmark_model =
1523 ios::BookmarkModelFactory::GetForBrowserState( 1532 ios::BookmarkModelFactory::GetForBrowserState(
1524 chrome_test_util::GetOriginalBrowserState()); 1533 chrome_test_util::GetOriginalBrowserState());
1525 1534
1526 const GURL firstURL = web::test::HttpServer::MakeUrl( 1535 const GURL firstURL = web::test::HttpServer::MakeUrl(
1527 "http://ios/testing/data/http_server_files/pony.html"); 1536 "http://ios/testing/data/http_server_files/pony.html");
1528 NSString* firstTitle = @"First URL"; 1537 NSString* firstTitle = @"First URL";
1529 bookmark_model->AddURL(bookmark_model->mobile_node(), 0, 1538 bookmark_model->AddURL(bookmark_model->mobile_node(), 0,
1530 base::SysNSStringToUTF16(firstTitle), firstURL); 1539 base::SysNSStringToUTF16(firstTitle), firstURL);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 continue; 1622 continue;
1614 // This is a folder. 1623 // This is a folder.
1615 if (bookmark->GetTitle() == folderTitle16) 1624 if (bookmark->GetTitle() == folderTitle16)
1616 return YES; 1625 return YES;
1617 } 1626 }
1618 return NO; 1627 return NO;
1619 } 1628 }
1620 1629
1621 // Asserts that there is a bookmark folder with the given title. 1630 // Asserts that there is a bookmark folder with the given title.
1622 + (void)assertFolderExistsWithTitle:(NSString*)folderTitle { 1631 + (void)assertFolderExistsWithTitle:(NSString*)folderTitle {
1623 GREYAssert([[self class] folderExistsWithTitle:folderTitle], 1632 GREYAssert([BookmarksTestCase folderExistsWithTitle:folderTitle],
1624 @"There is no folder named %@", folderTitle); 1633 @"There is no folder named %@", folderTitle);
1625 } 1634 }
1626 1635
1627 // Asserts that there is no bookmark folder with the given title. 1636 // Asserts that there is no bookmark folder with the given title.
1628 + (void)assertFolderDoesntExistWithTitle:(NSString*)folderTitle { 1637 + (void)assertFolderDoesntExistWithTitle:(NSString*)folderTitle {
1629 GREYAssert(![[self class] folderExistsWithTitle:folderTitle], 1638 GREYAssert(![BookmarksTestCase folderExistsWithTitle:folderTitle],
1630 @"There is a folder named %@", folderTitle); 1639 @"There is a folder named %@", folderTitle);
1631 } 1640 }
1632 1641
1633 // Deletes via the UI the currently focused folder. This must be called once 1642 // Deletes via the UI the currently focused folder. This must be called once
1634 // already in a non permanent folder (i.e. not Mobile Bookmarks, etc.). 1643 // already in a non permanent folder (i.e. not Mobile Bookmarks, etc.).
1635 + (void)deleteSelectedFolder { 1644 + (void)deleteSelectedFolder {
1636 // Enter edit mode. 1645 // Enter edit mode.
1637 [[EarlGrey 1646 [[EarlGrey
1638 selectElementWithMatcher:grey_accessibilityID(@"Edit_navigation_bar")] 1647 selectElementWithMatcher:grey_accessibilityID(@"Edit_navigation_bar")]
1639 performAction:grey_tap()]; 1648 performAction:grey_tap()];
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 if (!IsCompact()) { 1689 if (!IsCompact()) {
1681 [[EarlGrey selectElementWithMatcher:StarButton()] performAction:grey_tap()]; 1690 [[EarlGrey selectElementWithMatcher:StarButton()] performAction:grey_tap()];
1682 } else { 1691 } else {
1683 [ChromeEarlGreyUI openToolsMenu]; 1692 [ChromeEarlGreyUI openToolsMenu];
1684 [[EarlGrey selectElementWithMatcher:AddBookmarkButton()] 1693 [[EarlGrey selectElementWithMatcher:AddBookmarkButton()]
1685 performAction:grey_tap()]; 1694 performAction:grey_tap()];
1686 } 1695 }
1687 } 1696 }
1688 1697
1689 @end 1698 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/bookmarks/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698