Commit 480b2f89 authored by Rohit Rao's avatar Rohit Rao Committed by Commit Bot

[ios] Modifies ChromeTestCase to inherit from BaseEarlGreyTestCase.

BUG=922813

Change-Id: If16aeb9020ccca4c7d79e9519934bf163906a4ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1628831Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Rohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663174}
parent fad5b0b0
...@@ -8,11 +8,12 @@ ...@@ -8,11 +8,12 @@
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
#import "base/ios/block_types.h" #import "base/ios/block_types.h"
#import "ios/testing/earl_grey/base_earl_grey_test_case.h"
#import "ios/testing/earl_grey/disabled_test_macros.h" #import "ios/testing/earl_grey/disabled_test_macros.h"
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
// Base class for all Chrome Earl Grey tests. // Base class for all Chrome Earl Grey tests.
@interface ChromeTestCase : XCTestCase @interface ChromeTestCase : BaseEarlGreyTestCase
// Removes any UI elements that are present, to ensure it is in a clean state. // Removes any UI elements that are present, to ensure it is in a clean state.
+ (void)removeAnyOpenMenusAndInfoBars; + (void)removeAnyOpenMenusAndInfoBars;
......
...@@ -144,6 +144,7 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeTestCaseAppInterface) ...@@ -144,6 +144,7 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeTestCaseAppInterface)
// Overrides testInvocations so the set of tests run can be modified, as // Overrides testInvocations so the set of tests run can be modified, as
// necessary. // necessary.
+ (NSArray*)testInvocations { + (NSArray*)testInvocations {
#if defined(CHROME_EARL_GREY_1)
NSError* error = nil; NSError* error = nil;
[[EarlGrey selectElementWithMatcher:grey_systemAlertViewShown()] [[EarlGrey selectElementWithMatcher:grey_systemAlertViewShown()]
assertWithMatcher:grey_nil() assertWithMatcher:grey_nil()
...@@ -161,8 +162,9 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeTestCaseAppInterface) ...@@ -161,8 +162,9 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeTestCaseAppInterface)
[NSInvocation invocationWithMethodSignature:signature]; [NSInvocation invocationWithMethodSignature:signature];
systemAlertTest.selector = @selector(failAllTestsDueToSystemAlertVisible); systemAlertTest.selector = @selector(failAllTestsDueToSystemAlertVisible);
return @[ systemAlertTest ]; return @[ systemAlertTest ];
#endif #endif // !TARGET_IPHONE_SIMULATOR
} }
#endif // defined(CHROME_EARL_GREY_1)
// Return specific list of tests based on the target. // Return specific list of tests based on the target.
NSString* targetName = [NSBundle mainBundle].infoDictionary[@"CFBundleName"]; NSString* targetName = [NSBundle mainBundle].infoDictionary[@"CFBundleName"];
...@@ -177,11 +179,22 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeTestCaseAppInterface) ...@@ -177,11 +179,22 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeTestCaseAppInterface)
} }
} }
#if defined(CHROME_EARL_GREY_1)
+ (void)setUp {
[super setUp];
[ChromeTestCase setUpHelper];
}
#elif defined(CHROME_EARL_GREY_2)
+ (void)setUpForTestCase {
[super setUpForTestCase];
[ChromeTestCase setUpHelper];
}
#endif // CHROME_EARL_GREY_2
// Set up called once for the class, to dismiss anything displayed on startup // Set up called once for the class, to dismiss anything displayed on startup
// and revert browser settings to default. It also starts the HTTP server and // and revert browser settings to default. It also starts the HTTP server and
// enables mock authentication. // enables mock authentication.
+ (void)setUp { + (void)setUpHelper {
[super setUp];
[[self class] startHTTPServer]; [[self class] startHTTPServer];
[[self class] enableMockAuthentication]; [[self class] enableMockAuthentication];
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h" #import "ios/chrome/test/earl_grey/chrome_error_util.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/chrome/test/earl_grey2/chrome_earl_grey_edo.h" #import "ios/chrome/test/earl_grey2/chrome_earl_grey_edo.h"
#import "ios/testing/earl_grey/base_earl_grey_test_case.h"
#import "ios/testing/earl_grey/earl_grey_test.h" #import "ios/testing/earl_grey/earl_grey_test.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
// Test case to verify that EarlGrey tests can be launched and perform basic // Test case to verify that EarlGrey tests can be launched and perform basic
// UI interactions. // UI interactions.
@interface Eg2TestCase : BaseEarlGreyTestCase @interface SmokeTestCase : ChromeTestCase
@end @end
@implementation Eg2TestCase @implementation SmokeTestCase
// Tests that a tab can be opened. // Tests that a tab can be opened.
- (void)testOpenTab { - (void)testOpenTab {
...@@ -126,7 +126,6 @@ ...@@ -126,7 +126,6 @@
[ChromeEarlGrey closeAllIncognitoTabs]; [ChromeEarlGrey closeAllIncognitoTabs];
[ChromeEarlGrey openNewTab]; [ChromeEarlGrey openNewTab];
[ChromeEarlGrey closeCurrentTab]; [ChromeEarlGrey closeCurrentTab];
[ChromeEarlGrey openNewTab];
} }
// Tests bookmark converted helpers in chrome_earl_grey.h. // Tests bookmark converted helpers in chrome_earl_grey.h.
......
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