Commit 77360111 authored by Rohit Rao's avatar Rohit Rao Committed by Commit Bot

[ios] Prepares bookmarks_egtest.mm for EG2 conversion.

Updates to use the new backwards-compatible header and modifies some
calls that have changed syntax in EG2.  With this CL, the tests
themselves remain running as EG1 tests.

BUG=987646

Change-Id: I9957c69cfa042224b55015d93236a133f2e7c9e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1869470Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: Rohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707407}
parent b4607954
...@@ -153,7 +153,11 @@ source_set("unit_tests") { ...@@ -153,7 +153,11 @@ source_set("unit_tests") {
} }
source_set("eg_tests") { source_set("eg_tests") {
configs += [ "//build/config/compiler:enable_arc" ] defines = [ "CHROME_EARL_GREY_1" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true testonly = true
sources = [ sources = [
"bookmarks_egtest.mm", "bookmarks_egtest.mm",
...@@ -183,13 +187,11 @@ source_set("eg_tests") { ...@@ -183,13 +187,11 @@ source_set("eg_tests") {
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support", "//ios/chrome/test/earl_grey:test_support",
"//ios/public/provider/chrome/browser/signin:test_support", "//ios/public/provider/chrome/browser/signin:test_support",
"//ios/testing/earl_grey:earl_grey_support",
"//ios/third_party/earl_grey:earl_grey+link", "//ios/third_party/earl_grey:earl_grey+link",
"//ios/web/public/test/http_server", "//ios/web/public/test/http_server",
"//ui/base", "//ui/base",
"//url", "//url",
] ]
libs = [ libs = [ "UIKit.framework" ]
"UIKit.framework",
"XCTest.framework",
]
} }
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import <EarlGrey/EarlGrey.h>
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
#include <vector> #include <vector>
...@@ -41,6 +40,7 @@ ...@@ -41,6 +40,7 @@
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h" #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.h" #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#import "ios/web/public/test/http_server/http_server.h" #import "ios/web/public/test/http_server/http_server.h"
#include "ios/web/public/test/http_server/http_server_util.h" #include "ios/web/public/test/http_server/http_server_util.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -104,8 +104,8 @@ id<GREYMatcher> NavigateBackButtonTo(NSString* previousViewControllerLabel) { ...@@ -104,8 +104,8 @@ id<GREYMatcher> NavigateBackButtonTo(NSString* previousViewControllerLabel) {
grey_anyOf(grey_accessibilityLabel(previousViewControllerLabel), grey_anyOf(grey_accessibilityLabel(previousViewControllerLabel),
grey_accessibilityLabel(@"Back"), nil); grey_accessibilityLabel(@"Back"), nil);
return grey_allOf(grey_kindOfClass([UIButton class]), return grey_allOf(grey_kindOfClassName(@"UIButton"),
grey_ancestor(grey_kindOfClass([UINavigationBar class])), grey_ancestor(grey_kindOfClassName(@"UINavigationBar")),
buttonLabelMatcher, nil); buttonLabelMatcher, nil);
} }
...@@ -397,7 +397,7 @@ id<GREYMatcher> SearchIconButton() { ...@@ -397,7 +397,7 @@ id<GREYMatcher> SearchIconButton() {
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_allOf( selectElementWithMatcher:grey_allOf(
grey_accessibilityID(@"Mobile Bookmarks"), grey_accessibilityID(@"Mobile Bookmarks"),
grey_kindOfClass([UITableViewCell class]), grey_kindOfClassName(@"UITableViewCell"),
nil)] assertWithMatcher:grey_nil()]; nil)] assertWithMatcher:grey_nil()];
// Open the first folder, to be able to go back twice on the bookmarks. // Open the first folder, to be able to go back twice on the bookmarks.
...@@ -977,8 +977,7 @@ id<GREYMatcher> SearchIconButton() { ...@@ -977,8 +977,7 @@ id<GREYMatcher> SearchIconButton() {
+ (void)openBookmarkFolder:(NSString*)bookmarkFolder { + (void)openBookmarkFolder:(NSString*)bookmarkFolder {
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_allOf( selectElementWithMatcher:grey_allOf(
grey_kindOfClass( grey_kindOfClassName(@"UITableViewCell"),
NSClassFromString(@"UITableViewCell")),
grey_descendant(grey_text(bookmarkFolder)), grey_descendant(grey_text(bookmarkFolder)),
nil)] performAction:grey_tap()]; nil)] performAction:grey_tap()];
} }
...@@ -1515,8 +1514,7 @@ id<GREYMatcher> SearchIconButton() { ...@@ -1515,8 +1514,7 @@ id<GREYMatcher> SearchIconButton() {
+ (void)verifyBookmarkFolderIsSeen:(NSString*)bookmarkFolder { + (void)verifyBookmarkFolderIsSeen:(NSString*)bookmarkFolder {
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_allOf( selectElementWithMatcher:grey_allOf(
grey_kindOfClass( grey_kindOfClassName(@"UITableViewCell"),
NSClassFromString(@"UITableViewCell")),
grey_descendant(grey_text(bookmarkFolder)), grey_descendant(grey_text(bookmarkFolder)),
nil)] nil)]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
...@@ -1850,7 +1848,7 @@ id<GREYMatcher> SearchIconButton() { ...@@ -1850,7 +1848,7 @@ id<GREYMatcher> SearchIconButton() {
// Verify the delete confirmation button shows up. // Verify the delete confirmation button shows up.
[[[EarlGrey selectElementWithMatcher:BookmarksDeleteSwipeButton()] [[[EarlGrey selectElementWithMatcher:BookmarksDeleteSwipeButton()]
inRoot:grey_kindOfClass(NSClassFromString(@"UITableView"))] inRoot:grey_kindOfClassName(@"UITableView")]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
// Change to edit mode // Change to edit mode
...@@ -1861,7 +1859,7 @@ id<GREYMatcher> SearchIconButton() { ...@@ -1861,7 +1859,7 @@ id<GREYMatcher> SearchIconButton() {
// Verify the delete confirmation button is gone after entering edit mode. // Verify the delete confirmation button is gone after entering edit mode.
[[[EarlGrey selectElementWithMatcher:BookmarksDeleteSwipeButton()] [[[EarlGrey selectElementWithMatcher:BookmarksDeleteSwipeButton()]
inRoot:grey_kindOfClass(NSClassFromString(@"UITableView"))] inRoot:grey_kindOfClassName(@"UITableView")]
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
// Swipe action on "Second URL". This should not bring out delete // Swipe action on "Second URL". This should not bring out delete
...@@ -1872,7 +1870,7 @@ id<GREYMatcher> SearchIconButton() { ...@@ -1872,7 +1870,7 @@ id<GREYMatcher> SearchIconButton() {
// Verify the delete confirmation button doesn't appear. // Verify the delete confirmation button doesn't appear.
[[[EarlGrey selectElementWithMatcher:BookmarksDeleteSwipeButton()] [[[EarlGrey selectElementWithMatcher:BookmarksDeleteSwipeButton()]
inRoot:grey_kindOfClass(NSClassFromString(@"UITableView"))] inRoot:grey_kindOfClassName(@"UITableView")]
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
// Cancel edit mode // Cancel edit mode
...@@ -1886,7 +1884,7 @@ id<GREYMatcher> SearchIconButton() { ...@@ -1886,7 +1884,7 @@ id<GREYMatcher> SearchIconButton() {
// Verify the delete confirmation button shows up. (swipe-to-delete is // Verify the delete confirmation button shows up. (swipe-to-delete is
// re-enabled). // re-enabled).
[[[EarlGrey selectElementWithMatcher:BookmarksDeleteSwipeButton()] [[[EarlGrey selectElementWithMatcher:BookmarksDeleteSwipeButton()]
inRoot:grey_kindOfClass(NSClassFromString(@"UITableView"))] inRoot:grey_kindOfClassName(@"UITableView")]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
} }
...@@ -4634,8 +4632,7 @@ id<GREYMatcher> SearchIconButton() { ...@@ -4634,8 +4632,7 @@ id<GREYMatcher> SearchIconButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Verify search bar is enabled. // Verify search bar is enabled.
[[EarlGrey selectElementWithMatcher:grey_kindOfClass( [[EarlGrey selectElementWithMatcher:grey_kindOfClassName(@"UISearchBar")]
NSClassFromString(@"UISearchBar"))]
assertWithMatcher:grey_userInteractionEnabled()]; assertWithMatcher:grey_userInteractionEnabled()];
// Change to edit mode // Change to edit mode
...@@ -4645,16 +4642,14 @@ id<GREYMatcher> SearchIconButton() { ...@@ -4645,16 +4642,14 @@ id<GREYMatcher> SearchIconButton() {
performAction:grey_tap()]; performAction:grey_tap()];
// Verify search bar is disabled. // Verify search bar is disabled.
[[EarlGrey selectElementWithMatcher:grey_kindOfClass( [[EarlGrey selectElementWithMatcher:grey_kindOfClassName(@"UISearchBar")]
NSClassFromString(@"UISearchBar"))]
assertWithMatcher:grey_not(grey_userInteractionEnabled())]; assertWithMatcher:grey_not(grey_userInteractionEnabled())];
// Cancel edito mode. // Cancel edito mode.
[BookmarksTestCase closeContextBarEditMode]; [BookmarksTestCase closeContextBarEditMode];
// Verify search bar is enabled. // Verify search bar is enabled.
[[EarlGrey selectElementWithMatcher:grey_kindOfClass( [[EarlGrey selectElementWithMatcher:grey_kindOfClassName(@"UISearchBar")]
NSClassFromString(@"UISearchBar"))]
assertWithMatcher:grey_userInteractionEnabled()]; assertWithMatcher:grey_userInteractionEnabled()];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment