OLD | NEW |
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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 620 |
621 // Load the menu for a bookmark. | 621 // Load the menu for a bookmark. |
622 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] | 622 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] |
623 performAction:grey_tap()]; | 623 performAction:grey_tap()]; |
624 | 624 |
625 // Tap the edit action. | 625 // Tap the edit action. |
626 [[EarlGrey selectElementWithMatcher:actionSheet(ActionEdit)] | 626 [[EarlGrey selectElementWithMatcher:actionSheet(ActionEdit)] |
627 performAction:grey_tap()]; | 627 performAction:grey_tap()]; |
628 | 628 |
629 // Replace the title field with new text. | 629 // Replace the title field with new text. |
630 // TODO(crbug.com/644730): Use grey_replaceText instead of | |
631 // grey_clearText/grey_typeText when EarlGrey's issue is fixed: | |
632 // https://github.com/google/EarlGrey/issues/253 | |
633 [[EarlGrey | 630 [[EarlGrey |
634 selectElementWithMatcher:grey_accessibilityID(@"Title Field_textField")] | 631 selectElementWithMatcher:grey_accessibilityID(@"Title Field_textField")] |
635 performAction:grey_clearText()]; | 632 performAction:grey_replaceText(@"n5")]; |
636 [[EarlGrey | |
637 selectElementWithMatcher:grey_accessibilityID(@"Title Field_textField")] | |
638 performAction:grey_typeText(@"n5")]; | |
639 | 633 |
640 // Replace the url field with new text. | 634 // Replace the url field with new text. |
641 // TODO(crbug.com/644730): Use grey_replaceText instead of | |
642 // grey_clearText/grey_typeText when EarlGrey's issue is fixed: | |
643 // https://github.com/google/EarlGrey/issues/253 | |
644 [[EarlGrey | 635 [[EarlGrey |
645 selectElementWithMatcher:grey_accessibilityID(@"URL Field_textField")] | 636 selectElementWithMatcher:grey_accessibilityID(@"URL Field_textField")] |
646 performAction:grey_clearText()]; | 637 performAction:grey_replaceText(@"www.a.fr")]; |
647 [[EarlGrey | |
648 selectElementWithMatcher:grey_accessibilityID(@"URL Field_textField")] | |
649 performAction:grey_typeText(@"www.a.fr")]; | |
650 | 638 |
651 // Dismiss editor. | 639 // Dismiss editor. |
652 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] | 640 [[EarlGrey selectElementWithMatcher:bookmarksDoneButton()] |
653 performAction:grey_tap()]; | 641 performAction:grey_tap()]; |
654 [[EarlGrey | 642 [[EarlGrey |
655 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] | 643 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] |
656 assertWithMatcher:grey_notVisible()]; | 644 assertWithMatcher:grey_notVisible()]; |
657 | 645 |
658 // Verify that the bookmark was updated. | 646 // Verify that the bookmark was updated. |
659 [[EarlGrey selectElementWithMatcher:buttonWithAccessibilityLabel(@"n5")] | 647 [[EarlGrey selectElementWithMatcher:buttonWithAccessibilityLabel(@"n5")] |
660 assertWithMatcher:grey_sufficientlyVisible()]; | 648 assertWithMatcher:grey_sufficientlyVisible()]; |
661 [[self class] assertExistenceOfBookmarkWithURL:@"http://www.a.fr" name:@"n5"]; | 649 [[self class] assertExistenceOfBookmarkWithURL:@"http://www.a.fr" name:@"n5"]; |
662 } | 650 } |
663 | 651 |
664 // Tests that cancelling editing a single bookmark correctly doesn't persist | 652 // Tests that cancelling editing a single bookmark correctly doesn't persist |
665 // data. | 653 // data. |
666 - (void)testSingleBookmarkCancelEdit { | 654 - (void)testSingleBookmarkCancelEdit { |
667 [[self class] setupStandardBookmarks]; | 655 [[self class] setupStandardBookmarks]; |
668 [[self class] openTopLevelBookmarksFolder]; | 656 [[self class] openTopLevelBookmarksFolder]; |
669 | 657 |
670 // Load the menu for a bookmark. | 658 // Load the menu for a bookmark. |
671 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] | 659 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"First URL Info")] |
672 performAction:grey_tap()]; | 660 performAction:grey_tap()]; |
673 | 661 |
674 // Tap the edit action. | 662 // Tap the edit action. |
675 [[EarlGrey selectElementWithMatcher:actionSheet(ActionEdit)] | 663 [[EarlGrey selectElementWithMatcher:actionSheet(ActionEdit)] |
676 performAction:grey_tap()]; | 664 performAction:grey_tap()]; |
677 | 665 |
678 // Replace the title field with new text. | 666 // Replace the title field with new text. |
679 // TODO(crbug.com/644730): Use grey_replaceText instead of | |
680 // grey_clearText/grey_typeText when EarlGrey's issue is fixed: | |
681 // https://github.com/google/EarlGrey/issues/253 | |
682 [[EarlGrey | 667 [[EarlGrey |
683 selectElementWithMatcher:grey_accessibilityID(@"Title Field_textField")] | 668 selectElementWithMatcher:grey_accessibilityID(@"Title Field_textField")] |
684 performAction:grey_clearText()]; | 669 performAction:grey_replaceText(@"n5")]; |
685 [[EarlGrey | |
686 selectElementWithMatcher:grey_accessibilityID(@"Title Field_textField")] | |
687 performAction:grey_typeText(@"n5")]; | |
688 | 670 |
689 // Replace the url field with new text. | 671 // Replace the url field with new text. |
690 // TODO(crbug.com/644730): Use grey_replaceText instead of | |
691 // grey_clearText/grey_typeText when EarlGrey's issue is fixed: | |
692 // https://github.com/google/EarlGrey/issues/253 | |
693 [[EarlGrey | 672 [[EarlGrey |
694 selectElementWithMatcher:grey_accessibilityID(@"URL Field_textField")] | 673 selectElementWithMatcher:grey_accessibilityID(@"URL Field_textField")] |
695 performAction:grey_clearText()]; | 674 performAction:grey_replaceText(@"www.a.fr")]; |
696 [[EarlGrey | |
697 selectElementWithMatcher:grey_accessibilityID(@"URL Field_textField")] | |
698 performAction:grey_typeText(@"www.a.fr")]; | |
699 | 675 |
700 // Dismiss editor with Cancel button. | 676 // Dismiss editor with Cancel button. |
701 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Cancel")] | 677 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Cancel")] |
702 performAction:grey_tap()]; | 678 performAction:grey_tap()]; |
703 [[EarlGrey | 679 [[EarlGrey |
704 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] | 680 selectElementWithMatcher:grey_accessibilityID(@"Single Bookmark Editor")] |
705 assertWithMatcher:grey_notVisible()]; | 681 assertWithMatcher:grey_notVisible()]; |
706 | 682 |
707 // Verify that the bookmark was not updated. | 683 // Verify that the bookmark was not updated. |
708 [[EarlGrey selectElementWithMatcher:buttonWithAccessibilityLabel(@"n5")] | 684 [[EarlGrey selectElementWithMatcher:buttonWithAccessibilityLabel(@"n5")] |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 - (void)testEditFolder { | 721 - (void)testEditFolder { |
746 [[self class] setupStandardBookmarks]; | 722 [[self class] setupStandardBookmarks]; |
747 [[self class] openBookmarkFolder:@"Folder 1"]; | 723 [[self class] openBookmarkFolder:@"Folder 1"]; |
748 | 724 |
749 // Tap the Edit button in the navigation bar. | 725 // Tap the Edit button in the navigation bar. |
750 [[EarlGrey | 726 [[EarlGrey |
751 selectElementWithMatcher:grey_accessibilityID(@"Edit_navigation_bar")] | 727 selectElementWithMatcher:grey_accessibilityID(@"Edit_navigation_bar")] |
752 performAction:grey_tap()]; | 728 performAction:grey_tap()]; |
753 | 729 |
754 // Change the title. | 730 // Change the title. |
755 // TODO(crbug.com/644730): Use grey_replaceText instead of | |
756 // grey_clearText/grey_typeText when EarlGrey's issue is fixed: | |
757 // https://github.com/google/EarlGrey/issues/253 | |
758 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")] | 731 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")] |
759 performAction:grey_clearText()]; | 732 performAction:grey_replaceText(@"Renamed Folder")]; |
760 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")] | |
761 performAction:grey_typeText(@"Renamed Folder")]; | |
762 | 733 |
763 // Cancel without saving. | 734 // Cancel without saving. |
764 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Cancel")] | 735 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Cancel")] |
765 performAction:grey_tap()]; | 736 performAction:grey_tap()]; |
766 | 737 |
767 // Check that Folder 1 still exists at this name, and Renamed Folder doesn't. | 738 // Check that Folder 1 still exists at this name, and Renamed Folder doesn't. |
768 [[self class] assertFolderExistsWithTitle:@"Folder 1"]; | 739 [[self class] assertFolderExistsWithTitle:@"Folder 1"]; |
769 [[self class] assertFolderDoesntExistWithTitle:@"Renamed Folder"]; | 740 [[self class] assertFolderDoesntExistWithTitle:@"Renamed Folder"]; |
770 | 741 |
771 // Tap the Edit button in the navigation bar. | 742 // Tap the Edit button in the navigation bar. |
772 [[EarlGrey | 743 [[EarlGrey |
773 selectElementWithMatcher:grey_accessibilityID(@"Edit_navigation_bar")] | 744 selectElementWithMatcher:grey_accessibilityID(@"Edit_navigation_bar")] |
774 performAction:grey_tap()]; | 745 performAction:grey_tap()]; |
775 | 746 |
776 // Change the title. | 747 // Change the title. |
777 // TODO(crbug.com/644730): Use grey_replaceText instead of | |
778 // grey_clearText/grey_typeText when EarlGrey's issue is fixed: | |
779 // https://github.com/google/EarlGrey/issues/253 | |
780 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")] | 748 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")] |
781 performAction:grey_clearText()]; | 749 performAction:grey_replaceText(@"Renamed Folder")]; |
782 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Title_textField")] | |
783 performAction:grey_typeText(@"Renamed Folder")]; | |
784 | 750 |
785 // Save. | 751 // Save. |
786 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Save")] | 752 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Save")] |
787 performAction:grey_tap()]; | 753 performAction:grey_tap()]; |
788 | 754 |
789 // Check that Folder 1 doesn't exist and Renamed Folder does. | 755 // Check that Folder 1 doesn't exist and Renamed Folder does. |
790 [[self class] assertFolderDoesntExistWithTitle:@"Folder 1"]; | 756 [[self class] assertFolderDoesntExistWithTitle:@"Folder 1"]; |
791 [[self class] assertFolderExistsWithTitle:@"Renamed Folder"]; | 757 [[self class] assertFolderExistsWithTitle:@"Renamed Folder"]; |
792 } | 758 } |
793 | 759 |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 [[EarlGrey | 1328 [[EarlGrey |
1363 selectElementWithMatcher:grey_accessibilityID(@"Create New Folder")] | 1329 selectElementWithMatcher:grey_accessibilityID(@"Create New Folder")] |
1364 performAction:grey_tap()]; | 1330 performAction:grey_tap()]; |
1365 | 1331 |
1366 // Verify the folder creator is displayed. | 1332 // Verify the folder creator is displayed. |
1367 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Creator")] | 1333 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder Creator")] |
1368 assertWithMatcher:grey_sufficientlyVisible()]; | 1334 assertWithMatcher:grey_sufficientlyVisible()]; |
1369 | 1335 |
1370 // Change the name of the folder. | 1336 // Change the name of the folder. |
1371 if (name.length > 0) { | 1337 if (name.length > 0) { |
1372 // TODO(crbug.com/644730): Use grey_replaceText instead of | |
1373 // grey_clearText/grey_typeText when EarlGrey's issue is fixed: | |
1374 // https://github.com/google/EarlGrey/issues/253 | |
1375 [[EarlGrey | 1338 [[EarlGrey |
1376 selectElementWithMatcher:grey_accessibilityID(@"Title_textField")] | 1339 selectElementWithMatcher:grey_accessibilityID(@"Title_textField")] |
1377 performAction:grey_clearText()]; | 1340 performAction:grey_replaceText(name)]; |
1378 [[EarlGrey | |
1379 selectElementWithMatcher:grey_accessibilityID(@"Title_textField")] | |
1380 performAction:grey_typeText(name)]; | |
1381 } | 1341 } |
1382 | 1342 |
1383 // Tap the Save button. | 1343 // Tap the Save button. |
1384 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Save")] | 1344 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Save")] |
1385 performAction:grey_tap()]; | 1345 performAction:grey_tap()]; |
1386 } | 1346 } |
1387 | 1347 |
1388 // Loads a set of default bookmarks in the model for the tests to use. | 1348 // Loads a set of default bookmarks in the model for the tests to use. |
1389 + (void)setupStandardBookmarks { | 1349 + (void)setupStandardBookmarks { |
1390 [[self class] waitForBookmarkModelLoaded:YES]; | 1350 [[self class] waitForBookmarkModelLoaded:YES]; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 if (!IsCompact()) { | 1510 if (!IsCompact()) { |
1551 [[EarlGrey selectElementWithMatcher:starButton()] performAction:grey_tap()]; | 1511 [[EarlGrey selectElementWithMatcher:starButton()] performAction:grey_tap()]; |
1552 } else { | 1512 } else { |
1553 [ChromeEarlGreyUI openToolsMenu]; | 1513 [ChromeEarlGreyUI openToolsMenu]; |
1554 [[EarlGrey selectElementWithMatcher:addBookmarkButton()] | 1514 [[EarlGrey selectElementWithMatcher:addBookmarkButton()] |
1555 performAction:grey_tap()]; | 1515 performAction:grey_tap()]; |
1556 } | 1516 } |
1557 } | 1517 } |
1558 | 1518 |
1559 @end | 1519 @end |
OLD | NEW |