Commit d0889865 authored by zhaoyangli's avatar zhaoyangli Committed by Commit Bot

[iOS][EG2] Replace -launchAppForTestMethod with -appConfigurationForTestCase

To make method calls logically cleaner. "TestMethod" is changed to
"TestCase" because this is a place to create a configuration that's used
across a TestCase.

Bug: 1058588
Change-Id: I6da6a19a2ac8321a5bd3c0d66bb36db55039211e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087985
Commit-Queue: Zhaoyang Li <zhaoyangli@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747403}
parent a3d61fb8
......@@ -15,7 +15,7 @@
#import "ios/chrome/browser/autofill/automation/automation_app_interface.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/testing/earl_grey/app_launch_manager.h"
#import "ios/testing/earl_grey/app_launch_configuration.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -92,12 +92,11 @@ base::Value RecipeJsonToValue(const std::string& recipe_json) {
return path;
}
- (void)launchAppForTestMethod {
[[AppLaunchManager sharedManager]
ensureAppLaunchedWithFeaturesEnabled:
{autofill::features::kAutofillShowTypePredictions}
disabled:{}
relaunchPolicy:NoForceRelaunchAndResetState];
- (AppLaunchConfiguration)appConfigurationForTestCase {
AppLaunchConfiguration config;
config.features_enabled.push_back(
autofill::features::kAutofillShowTypePredictions);
return config;
}
- (void)setUp {
......
......@@ -20,7 +20,7 @@
#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/testing/earl_grey/app_launch_manager.h"
#import "ios/testing/earl_grey/app_launch_configuration.h"
#import "ios/testing/earl_grey/disabled_test_macros.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#import "ios/web/public/test/http_server/http_server.h"
......@@ -85,11 +85,10 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
[super tearDown];
}
- (void)launchAppForTestMethod {
[[AppLaunchManager sharedManager]
ensureAppLaunchedWithFeaturesEnabled:{features::kCredentialManager}
disabled:{}
relaunchPolicy:NoForceRelaunchAndResetState];
- (AppLaunchConfiguration)appConfigurationForTestCase {
AppLaunchConfiguration config;
config.features_enabled.push_back(features::kCredentialManager);
return config;
}
#pragma mark - Utils
......
......@@ -12,7 +12,7 @@
#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/testing/earl_grey/app_launch_manager.h"
#import "ios/testing/earl_grey/app_launch_configuration.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#import "ios/testing/earl_grey/keyboard_app_interface.h"
#include "ios/web/public/test/element_selector.h"
......@@ -105,11 +105,10 @@ BOOL WaitForKeyboardToAppear() {
@implementation CreditCardViewControllerTestCase
- (void)launchAppForTestMethod {
[[AppLaunchManager sharedManager]
ensureAppLaunchedWithFeaturesEnabled:{kCreditCardScanner}
disabled:{}
relaunchPolicy:NoForceRelaunchAndResetState];
- (AppLaunchConfiguration)appConfigurationForTestCase {
AppLaunchConfiguration config;
config.features_enabled.push_back(kCreditCardScanner);
return config;
}
- (void)setUp {
......
......@@ -12,7 +12,7 @@
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/chrome/test/scoped_eg_synchronization_disabler.h"
#import "ios/testing/earl_grey/app_launch_manager.h"
#import "ios/testing/earl_grey/app_launch_configuration.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#include "ios/testing/embedded_test_server_handlers.h"
#include "ios/web/common/features.h"
......@@ -96,12 +96,10 @@ bool WaitForOpenInDownloadsButton() {
@implementation DownloadManagerTestCase
- (void)launchAppForTestMethod {
[[AppLaunchManager sharedManager]
ensureAppLaunchedWithFeaturesEnabled:
{web::features::kEnablePersistentDownloads}
disabled:{}
relaunchPolicy:NoForceRelaunchAndResetState];
- (AppLaunchConfiguration)appConfigurationForTestCase {
AppLaunchConfiguration config;
config.features_enabled.push_back(web::features::kEnablePersistentDownloads);
return config;
}
- (void)setUp {
......
......@@ -10,7 +10,7 @@
#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/testing/earl_grey/app_launch_manager.h"
#import "ios/testing/earl_grey/app_launch_configuration.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#include "ui/base/l10n/l10n_util_mac.h"
......@@ -90,11 +90,10 @@ id<GREYMatcher> CardNumberIconView(NSString* icon_type) {
@implementation AutofillAddCreditCardTestCase
- (void)launchAppForTestMethod {
[[AppLaunchManager sharedManager]
ensureAppLaunchedWithFeaturesEnabled:{kCreditCardScanner}
disabled:{}
relaunchPolicy:NoForceRelaunchAndResetState];
- (AppLaunchConfiguration)appConfigurationForTestCase {
AppLaunchConfiguration config;
config.features_enabled.push_back(kCreditCardScanner);
return config;
}
- (void)setUp {
......
......@@ -15,7 +15,7 @@
#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/testing/earl_grey/app_launch_manager.h"
#import "ios/testing/earl_grey/app_launch_configuration.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -60,11 +60,10 @@ id<GREYMatcher> NoBookmarksLabel() {
[super tearDown];
}
- (void)launchAppForTestMethod {
[[AppLaunchManager sharedManager]
ensureAppLaunchedWithFeaturesEnabled:{kClearSyncedData}
disabled:{}
relaunchPolicy:NoForceRelaunchAndResetState];
- (AppLaunchConfiguration)appConfigurationForTestCase {
AppLaunchConfiguration config;
config.features_enabled.push_back(kClearSyncedData);
return config;
}
- (void)setUp {
......
......@@ -40,13 +40,14 @@
// Otherwise, the app will be activated instead of (re)launched.
// Will wait until app is activated or launched, and fail the test if it
// fails to do so.
// |configuration| sets features, variations and relaunch manners.
// If you're trying to call this method in |-setUp()|, please put it in
// |-launchAppForTestMethod()| instead for better efficiency.
// |configuration| sets features, variations, arguments and relaunch manners.
// If you're trying to call this method in |-setUp()|, please specify an
// |AppLaunchConfiguration| in |-appConfigurationForTestCase()| instead for
// better efficiency.
- (void)ensureAppLaunchedWithConfiguration:
(AppLaunchConfiguration)configuration;
// See ensureAppLaunchedWithConfiguration: for details.
// DEPRECATED. Use |ensureAppLaunchedWithConfiguration:| instead.
- (void)ensureAppLaunchedWithFeaturesEnabled:
(std::vector<base::Feature>)featuresEnabled
disabled:(std::vector<base::Feature>)
......
......@@ -7,6 +7,8 @@
#import <XCTest/XCTest.h>
#import "ios/testing/earl_grey/app_launch_configuration.h"
// Base class for all Earl Grey tests.
// Provides EG1-compatible start-of-test-case hooks for EG2 tests,
// as well as handling common EG2 app-launching logic.
......@@ -24,12 +26,11 @@
// Invoked upon starting each test method in a test case.
- (void)setUp NS_REQUIRES_SUPER;
// Responsible for launching the app under test in EG2 tests.
// By default, will launch the app once per test process launch with
// default parameters; individual test cases can override this method if they
// wish to pass different parameters or provide different behavior.
// Protected method.
- (void)launchAppForTestMethod;
// Provides an |AppLaunchConfiguration| for host app used across a TestCase.
// Subclasses must override this method to change app launching configuration
// (f.e. features or flags). Default implementation returns default
// AppLaunchConfiguration object.
- (AppLaunchConfiguration)appConfigurationForTestCase;
@end
......
......@@ -10,6 +10,7 @@
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/strings/sys_string_conversions.h"
#import "ios/testing/earl_grey/app_launch_configuration.h"
#import "ios/testing/earl_grey/app_launch_manager.h"
#import "ios/testing/earl_grey/base_earl_grey_test_case_app_interface.h"
#import "ios/testing/earl_grey/coverage_utils.h"
......@@ -43,7 +44,8 @@ bool g_needs_set_up_for_test_case = true;
[super setUp];
#if defined(CHROME_EARL_GREY_2)
[self launchAppForTestMethod];
[[AppLaunchManager sharedManager]
ensureAppLaunchedWithConfiguration:[self appConfigurationForTestCase]];
[self handleSystemAlertIfVisible];
NSString* logFormat = @"*********************************\nStarting test: %@";
......@@ -112,10 +114,8 @@ bool g_needs_set_up_for_test_case = true;
#endif // CHROME_EARL_GREY_2
}
- (void)launchAppForTestMethod {
[[AppLaunchManager sharedManager] ensureAppLaunchedWithFeaturesEnabled:{}
disabled:{}
relaunchPolicy:NoForceRelaunchAndResetState];
- (AppLaunchConfiguration)appConfigurationForTestCase {
return AppLaunchConfiguration();
}
#pragma mark - Private
......
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