Commit 4b14f5d8 authored by Nazerke's avatar Nazerke Committed by Commit Bot

[iOS][eg2] Convert signin settings EG tests to EG2

This CL adds all signin settings tests to EG2 target
and updates headers and adds eg2_test source_set in
build file. New app interface for signin settings
tests is being introduced.

Bug: 987646

Change-Id: I6d888342c059b8b1767e910697b3f4d1a9b483e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1903192
Commit-Queue: Nazerke Kalidolda <nazerke@google.com>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Auto-Submit: Nazerke Kalidolda <nazerke@google.com>
Cr-Commit-Position: refs/heads/master@{#720941}
parent ee7c1784
......@@ -222,6 +222,7 @@ source_set("constants") {
}
source_set("test_support") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
......@@ -229,6 +230,8 @@ source_set("test_support") {
"passphrase_table_view_controller_test.mm",
"personal_data_manager_finished_profile_tasks_waiter.cc",
"personal_data_manager_finished_profile_tasks_waiter.h",
"signin_settings_app_interface.h",
"signin_settings_app_interface.mm",
]
deps = [
":settings",
......@@ -237,11 +240,13 @@ source_set("test_support") {
"//components/autofill/core/browser",
"//components/keyed_service/core",
"//components/pref_registry",
"//components/prefs",
"//components/sync",
"//components/sync:test_support",
"//components/sync_preferences",
"//components/sync_preferences:test_support",
"//google_apis",
"//ios/chrome/browser",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/browser_state:test_support",
"//ios/chrome/browser/main:test_support",
......@@ -252,6 +257,7 @@ source_set("test_support") {
"//ios/chrome/browser/sync:test_support",
"//ios/chrome/browser/ui/settings/password",
"//ios/chrome/browser/ui/table_view:test_support",
"//ios/chrome/test/app:test_support",
"//ios/public/provider/chrome/browser/signin:test_support",
"//ios/web/public/test",
"//testing/gtest",
......@@ -432,10 +438,14 @@ source_set("eg_app_support+eg2") {
sources = [
"block_popups_app_interface.h",
"block_popups_app_interface.mm",
"signin_settings_app_interface.h",
"signin_settings_app_interface.mm",
]
deps = [
"//base",
"//components/content_settings/core/browser",
"//components/prefs",
"//ios/chrome/browser",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/content_settings",
"//ios/chrome/test/app:test_support",
......@@ -451,6 +461,7 @@ source_set("eg_test_support+eg2") {
testonly = true
sources = [
"block_popups_app_interface.h",
"signin_settings_app_interface.h",
]
public_deps = [
"//components/content_settings/core/common",
......@@ -466,12 +477,17 @@ source_set("eg2_tests") {
testonly = true
sources = [
"block_popups_egtest.mm",
"signin_settings_egtest.mm",
]
deps = [
":eg_test_support+eg2",
"//base",
"//ios/chrome/app/strings",
"//ios/chrome/browser/ui/authentication:eg_test_support+eg2",
"//ios/chrome/browser/ui/authentication/cells:constants",
"//ios/chrome/browser/ui/settings:constants",
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//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",
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_SIGNIN_SETTINGS_APP_INTERFACE_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_SIGNIN_SETTINGS_APP_INTERFACE_H_
#import <UIKit/UIKit.h>
// The app interface for sign-in settings tests.
@interface SigninSettingsAppInterface : NSObject
// Sets the kIosSettingsSigninPromoDisplayedCount value, related to the
// number of time the sign-in promo has been displayed.
+ (void)setSettingsSigninPromoDisplayedCount:(int)displayedCount;
// Returns the kIosSettingsSigninPromoDisplayedCount value, related to
// the number of time the sign-in promo has been displayed.
+ (int)settingsSigninPromoDisplayedCount;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_SIGNIN_SETTINGS_APP_INTERFACE_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/signin_settings_app_interface.h"
#include "components/prefs/pref_service.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/pref_names.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation SigninSettingsAppInterface
+ (void)setSettingsSigninPromoDisplayedCount:(int)displayedCount {
ios::ChromeBrowserState* browserState =
chrome_test_util::GetOriginalBrowserState();
PrefService* prefService = browserState->GetPrefs();
prefService->SetInteger(prefs::kIosSettingsSigninPromoDisplayedCount,
displayedCount);
}
+ (int)settingsSigninPromoDisplayedCount {
ios::ChromeBrowserState* browserState =
chrome_test_util::GetOriginalBrowserState();
PrefService* prefService = browserState->GetPrefs();
return prefService->GetInteger(prefs::kIosSettingsSigninPromoDisplayedCount);
}
@end
......@@ -2,29 +2,31 @@
// 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"
#include "components/prefs/pref_service.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/pref_names.h"
#import "ios/chrome/browser/ui/authentication/cells/signin_promo_view_constants.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/browser/ui/settings/settings_table_view_controller_constants.h"
#import "ios/chrome/browser/ui/settings/signin_settings_app_interface.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.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"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#if defined(CHROME_EARL_GREY_2)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat-extra-semi"
GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(SigninSettingsAppInterface);
#pragma clang diagnostic pop
#endif // defined(CHROME_EARL_GREY_2)
using chrome_test_util::PrimarySignInButton;
using chrome_test_util::SecondarySignInButton;
using chrome_test_util::SettingsAccountButton;
......@@ -94,20 +96,17 @@ using chrome_test_util::ButtonWithAccessibilityLabelId;
// Tests that the sign-in promo should not be shown after been shown 5 times.
- (void)testAutomaticSigninPromoDismiss {
const int displayedCount = 19;
ios::ChromeBrowserState* browser_state =
chrome_test_util::GetOriginalBrowserState();
PrefService* prefs = browser_state->GetPrefs();
prefs->SetInteger(prefs::kIosSettingsSigninPromoDisplayedCount,
displayedCount);
[SigninSettingsAppInterface
setSettingsSigninPromoDisplayedCount:displayedCount];
[ChromeEarlGreyUI openSettingsMenu];
// Check the sign-in promo view is visible.
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeColdState];
// Check the sign-in promo will not be shown anymore.
GREYAssertEqual(
displayedCount + 1,
prefs->GetInteger(prefs::kIosSettingsSigninPromoDisplayedCount),
@"Should have incremented the display count");
int newDisplayedCount =
[SigninSettingsAppInterface settingsSigninPromoDisplayedCount];
GREYAssertEqual(displayedCount + 1, newDisplayedCount,
@"Should have incremented the display count");
// Close the settings menu and open it again.
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
......
......@@ -73,7 +73,6 @@ source_set("test_support") {
"//ios/chrome/browser/ui/main",
"//ios/chrome/browser/ui/settings",
"//ios/chrome/browser/ui/settings:settings_root",
"//ios/chrome/browser/ui/settings:test_support",
"//ios/chrome/browser/ui/settings/password",
"//ios/chrome/browser/ui/settings/password:test_support",
"//ios/chrome/browser/ui/static_content",
......
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