Commit c8ede4df authored by Nazerke's avatar Nazerke Committed by Commit Bot

[iOS][eg2] Convert SyncFakeServerTestCase to eg2.

This CL adds helper methods to signin_earlgrey_utils_app_interface.*
and converts the following tests:
-testSyncUploadBookmarkOnFirstSync
-testSyncUploadBookmark
-testSyncDownloadBookmark
-testSyncCheckSameCacheGuid_SyncRestarted
-testSyncCheckDifferentCacheGuid_SignOutAndSignIn
-testSyncCheckSameCacheGuid_SyncRestartedAfterSignOutAndSignIn
-testSyncDownloadAutofillProfile
-testSyncUpdateAutofillProfile
-testSyncDeleteAutofillProfile
-testSyncUploadOpenTabs
-testSyncTypedURLUpload
-testSyncTypedUrlDownload
-testSyncTypedURLDeleteFromClient
-testSyncTypedURLDeleteFromServer.

Bug: 987646

Change-Id: I559a90182f78996399bfc1ae9ac98a184c36d914
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1955555
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Auto-Submit: Nazerke Kalidolda <nazerke@google.com>
Cr-Commit-Position: refs/heads/master@{#727468}
parent 861dffb6
......@@ -164,8 +164,10 @@ source_set("eg_test_support") {
":authentication",
"unified_consent",
"//base/test:test_support",
"//components/bookmarks/browser",
"//components/signin/public/identity_manager",
"//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser/bookmarks",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/signin",
"//ios/chrome/browser/ui/authentication/cells",
......@@ -198,8 +200,10 @@ source_set("eg_app_support+eg2") {
deps = [
":authentication",
"unified_consent",
"//components/bookmarks/browser",
"//components/signin/public/identity_manager",
"//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser/bookmarks",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/signin",
"//ios/chrome/browser/ui/authentication/cells",
......
......@@ -15,6 +15,12 @@
// compiled into the app binary and can be called from either app or test code.
@interface SigninEarlGreyUtilsAppInterface : NSObject
// Returns a fake identity.
+ (FakeChromeIdentity*)fakeIdentity1;
// Returns a second fake identity.
+ (FakeChromeIdentity*)fakeIdentity2;
// Adds |fakeIdentity| to the fake identity service.
+ (void)addFakeIdentity:(FakeChromeIdentity*)fakeIdentity;
......@@ -34,6 +40,18 @@
// Removes |fakeIdentity| from the fake identity service.
+ (void)removeFakeIdentity:(FakeChromeIdentity*)fakeIdentity;
// Returns the current number of bookmarks from BookmarkModel.
+ (NSUInteger)bookmarkCount:(NSString*)title;
// Checks if any identity is currently authenticated.
+ (BOOL)isAuthenticated;
// Signs out the current user.
+ (void)signOut;
// Adds the new bookmark with URL and title to the |BookmarkModel|.
+ (void)addBookmark:(NSString*)urlString withTitle:(NSString*)title;
@end
#endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_EARLGREY_UTILS_APP_INTERFACE_H_
......@@ -5,15 +5,22 @@
#import "ios/chrome/browser/ui/authentication/signin_earlgrey_utils_app_interface.h"
#include "base/strings/sys_string_conversions.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/titled_url_match.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
#include "ios/chrome/browser/bookmarks/bookmarks_utils.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/signin/authentication_service.h"
#include "ios/chrome/browser/signin/authentication_service_factory.h"
#include "ios/chrome/browser/signin/identity_manager_factory.h"
#import "ios/chrome/browser/ui/authentication/unified_consent/identity_chooser/identity_chooser_cell.h"
#import "ios/chrome/test/app/chrome_test_util.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/testing/earl_grey/earl_grey_app.h"
#include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -21,6 +28,18 @@
@implementation SigninEarlGreyUtilsAppInterface
+ (FakeChromeIdentity*)fakeIdentity1 {
return [FakeChromeIdentity identityWithEmail:@"foo1@gmail.com"
gaiaID:@"foo1ID"
name:@"Fake Foo 1"];
}
+ (FakeChromeIdentity*)fakeIdentity2 {
return [FakeChromeIdentity identityWithEmail:@"foo2@gmail.com"
gaiaID:@"foo2ID"
name:@"Fake Foo 2"];
}
+ (void)addFakeIdentity:(FakeChromeIdentity*)fakeIdentity {
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
......@@ -60,4 +79,41 @@
->RemoveIdentity(fakeIdentity);
}
+ (NSUInteger)bookmarkCount:(NSString*)title {
bookmarks::BookmarkModel* bookmarkModel =
ios::BookmarkModelFactory::GetForBrowserState(
chrome_test_util::GetOriginalBrowserState());
base::string16 matchString = base::SysNSStringToUTF16(title);
std::vector<bookmarks::TitledUrlMatch> matches;
bookmarkModel->GetBookmarksMatching(matchString, 50, &matches);
const size_t count = matches.size();
return count;
}
+ (BOOL)isAuthenticated {
ios::ChromeBrowserState* browser_state =
chrome_test_util::GetOriginalBrowserState();
AuthenticationService* authentication_service =
AuthenticationServiceFactory::GetForBrowserState(browser_state);
return authentication_service->IsAuthenticated();
}
+ (void)signOut {
ios::ChromeBrowserState* browser_state =
chrome_test_util::GetOriginalBrowserState();
AuthenticationService* authentication_service =
AuthenticationServiceFactory::GetForBrowserState(browser_state);
authentication_service->SignOut(signin_metrics::SIGNOUT_TEST, nil);
}
+ (void)addBookmark:(NSString*)urlString withTitle:(NSString*)title {
GURL bookmarkURL = GURL(base::SysNSStringToUTF8(urlString));
bookmarks::BookmarkModel* bookmark_model =
ios::BookmarkModelFactory::GetForBrowserState(
chrome_test_util::GetOriginalBrowserState());
bookmark_model->AddURL(bookmark_model->mobile_node(), 0,
base::SysNSStringToUTF16(title), bookmarkURL);
}
@end
......@@ -35,6 +35,7 @@ source_set("utils") {
source_set("eg_tests") {
configs += [ "//build/config/compiler:enable_arc" ]
defines = [ "CHROME_EARL_GREY_1" ]
testonly = true
sources = [
"sync_fake_server_egtest.mm",
......@@ -50,8 +51,37 @@ source_set("eg_tests") {
"//ios/chrome/test/earl_grey:test_support",
"//ios/public/provider/chrome/browser/signin:fake_chrome_identity",
"//ios/public/provider/chrome/browser/signin:test_support",
"//ios/testing/earl_grey:earl_grey_support",
"//ios/third_party/earl_grey:earl_grey+link",
"//ios/web/public/test/http_server",
]
libs = [ "XCTest.framework" ]
}
source_set("eg2_tests") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"sync_fake_server_egtest.mm",
]
deps = [
"//base",
"//base/test:test_support",
"//ios/chrome/browser/ui/authentication:eg_test_support+eg2",
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/public/provider/chrome/browser/signin:fake_chrome_identity",
"//ios/public/provider/chrome/browser/signin:test_support",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
"//ios/web/public/test/http_server",
]
libs = [ "UIKit.framework" ]
}
......@@ -2,23 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <EarlGrey/EarlGrey.h>
#include "base/strings/sys_string_conversions.h"
#import "base/test/ios/wait_util.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/titled_url_match.h"
#include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
#include "ios/chrome/browser/signin/authentication_service.h"
#include "ios/chrome/browser/signin/authentication_service_factory.h"
#import "ios/chrome/browser/ui/authentication/signin_earl_grey_ui.h"
#import "ios/chrome/browser/ui/authentication/signin_earlgrey_utils.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/browser/ui/authentication/signin_earlgrey_utils_app_interface.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.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_service.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#import "ios/web/public/test/http_server/http_server.h"
#include "ios/web/public/test/http_server/http_server_util.h"
......@@ -26,8 +18,6 @@
#error "This file requires ARC support."
#endif
using chrome_test_util::SettingsDoneButton;
namespace {
// Constant for timeout while waiting for asynchronous sync operations.
......@@ -75,12 +65,12 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
// Tests that a bookmark added on the client (before Sync is enabled) is
// uploaded to the Sync server once Sync is turned on.
- (void)testSyncUploadBookmarkOnFirstSync {
[self addBookmark:GURL("https://www.foo.com") withTitle:@"foo"];
[self addBookmark:@"https://www.foo.com" withTitle:@"foo"];
// Sign in to sync, after a bookmark has been added.
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
// Assert that the correct number of bookmarks have been synced.
......@@ -90,14 +80,14 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
// Tests that a bookmark added on the client is uploaded to the Sync server.
- (void)testSyncUploadBookmark {
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
// Add a bookmark after sync is initialized.
[ChromeEarlGrey waitForSyncInitialized:YES syncTimeout:kSyncOperationTimeout];
[self addBookmark:GURL("https://www.goo.com") withTitle:@"goo"];
[self addBookmark:@"https://www.goo.com" withTitle:@"goo"];
AssertNumberOfEntities(1, syncer::BOOKMARKS);
}
......@@ -109,9 +99,9 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
[ChromeEarlGrey addFakeSyncServerBookmarkWithURL:URL title:"hoo"];
// Sign in to sync, after a bookmark has been injected in the sync server.
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
[ChromeEarlGrey waitForSyncInitialized:YES syncTimeout:kSyncOperationTimeout];
[[self class] assertBookmarksWithTitle:@"hoo" expectedCount:1];
......@@ -120,9 +110,9 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
// Tests that the local cache guid does not change when sync is restarted.
- (void)testSyncCheckSameCacheGuid_SyncRestarted {
// Sign in the fake identity.
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
[ChromeEarlGrey waitForSyncInitialized:YES syncTimeout:kSyncOperationTimeout];
......@@ -142,21 +132,16 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
// signs back in with the same account.
- (void)testSyncCheckDifferentCacheGuid_SignOutAndSignIn {
// Sign in a fake identity, and store the initial sync guid.
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
[ChromeEarlGrey waitForSyncInitialized:YES syncTimeout:kSyncOperationTimeout];
std::string original_guid = [ChromeEarlGrey syncCacheGUID];
// Sign out the current user.
ios::ChromeBrowserState* browser_state =
chrome_test_util::GetOriginalBrowserState();
AuthenticationService* authentication_service =
AuthenticationServiceFactory::GetForBrowserState(browser_state);
GREYAssert(authentication_service->IsAuthenticated(),
GREYAssert([SigninEarlGreyUtilsAppInterface isAuthenticated],
@"User is not signed in.");
authentication_service->SignOut(signin_metrics::SIGNOUT_TEST, nil);
[SigninEarlGreyUtilsAppInterface signOut];
[ChromeEarlGrey waitForSyncInitialized:NO syncTimeout:kSyncOperationTimeout];
// Sign the user back in, and verify the guid has changed.
......@@ -172,20 +157,15 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
// Test for http://crbug.com/413611 .
- (void)testSyncCheckSameCacheGuid_SyncRestartedAfterSignOutAndSignIn {
// Sign in a fake idenitty.
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
[ChromeEarlGrey waitForSyncInitialized:YES syncTimeout:kSyncOperationTimeout];
// Sign out the current user.
ios::ChromeBrowserState* browser_state =
chrome_test_util::GetOriginalBrowserState();
AuthenticationService* authentication_service =
AuthenticationServiceFactory::GetForBrowserState(browser_state);
GREYAssert(authentication_service->IsAuthenticated(),
GREYAssert([SigninEarlGreyUtilsAppInterface isAuthenticated],
@"User is not signed in.");
authentication_service->SignOut(signin_metrics::SIGNOUT_TEST, nil);
[SigninEarlGreyUtilsAppInterface signOut];
[ChromeEarlGrey waitForSyncInitialized:NO syncTimeout:kSyncOperationTimeout];
// Sign the user back in.
......@@ -218,9 +198,9 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
}];
// Sign in to sync.
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
// Verify that the autofill profile has been downloaded.
......@@ -247,9 +227,9 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
}];
// Sign in to sync.
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
// Verify that the autofill profile has been downloaded.
......@@ -294,9 +274,9 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
}];
// Sign in to sync.
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
// Verify that the autofill profile has been downloaded
......@@ -335,9 +315,9 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
[ChromeEarlGrey loadURL:URL2];
// Sign in to sync, after opening two tabs.
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
// Verify the sessions on the sync server.
......@@ -363,9 +343,9 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
[ChromeEarlGrey addHistoryServiceTypedURL:mockURL];
// Sign in to sync.
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
[ChromeEarlGrey waitForSyncInitialized:YES syncTimeout:kSyncOperationTimeout];
......@@ -391,9 +371,9 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
[ChromeEarlGrey addFakeSyncServerTypedURL:mockURL];
// Sign in to sync.
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
[ChromeEarlGrey waitForSyncInitialized:YES syncTimeout:kSyncOperationTimeout];
......@@ -418,9 +398,9 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
[ChromeEarlGrey addFakeSyncServerTypedURL:mockURL];
// Sign in to sync.
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
[ChromeEarlGrey waitForSyncInitialized:YES syncTimeout:kSyncOperationTimeout];
......@@ -453,9 +433,9 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
[ChromeEarlGrey addHistoryServiceTypedURL:mockURL];
// Sign in to sync.
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
fakeIdentity);
FakeChromeIdentity* fakeIdentity =
[SigninEarlGreyUtilsAppInterface fakeIdentity1];
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
[ChromeEarlGrey waitForSyncInitialized:YES syncTimeout:kSyncOperationTimeout];
......@@ -480,13 +460,9 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
// folder.
// TODO(crbug.com/646164): This is copied from bookmarks_egtest.mm and should
// move to common location.
- (void)addBookmark:(const GURL)url withTitle:(NSString*)title {
- (void)addBookmark:(NSString*)urlString withTitle:(NSString*)title {
[ChromeEarlGrey waitForBookmarksToFinishLoading];
bookmarks::BookmarkModel* bookmark_model =
ios::BookmarkModelFactory::GetForBrowserState(
chrome_test_util::GetOriginalBrowserState());
bookmark_model->AddURL(bookmark_model->mobile_node(), 0,
base::SysNSStringToUTF16(title), url);
[SigninEarlGreyUtilsAppInterface addBookmark:urlString withTitle:title];
}
// Asserts that |expectedCount| bookmarks exist with the corresponding |title|
......@@ -495,17 +471,9 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
// move to common location.
+ (void)assertBookmarksWithTitle:(NSString*)title
expectedCount:(NSUInteger)expectedCount {
// Get BookmarkModel and wait for it to be loaded.
bookmarks::BookmarkModel* bookmarkModel =
ios::BookmarkModelFactory::GetForBrowserState(
chrome_test_util::GetOriginalBrowserState());
// Verify the correct number of bookmarks exist.
base::string16 matchString = base::SysNSStringToUTF16(title);
std::vector<bookmarks::TitledUrlMatch> matches;
bookmarkModel->GetBookmarksMatching(matchString, 50, &matches);
const size_t count = matches.size();
GREYAssertEqual(expectedCount, count, @"Unexpected number of bookmarks");
GREYAssertEqual(expectedCount,
[SigninEarlGreyUtilsAppInterface bookmarkCount:title],
@"Unexpected number of bookmarks");
}
@end
......@@ -105,6 +105,7 @@ chrome_ios_eg2_test("ios_chrome_ui_eg2tests_module") {
"//ios/chrome/browser/ui/sad_tab:eg2_tests",
"//ios/chrome/browser/ui/safe_mode:eg2_tests",
"//ios/chrome/browser/ui/settings/google_services:eg2_tests",
"//ios/chrome/browser/ui/settings/sync/utils:eg2_tests",
"//ios/chrome/browser/ui/side_swipe:eg2_tests",
"//ios/chrome/browser/ui/signin_interaction:eg2_tests",
"//ios/chrome/browser/ui/tab_grid:eg2_tests",
......
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