Commit ac864acc authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[EG2] Convert SadTabView EGTest to EG2.

Bug: 987646
Change-Id: I08dab761f2443cadf49acf60acdbc3e4df9fbb7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1847679
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704401}
parent 161446e1
...@@ -76,6 +76,7 @@ source_set("unit_tests") { ...@@ -76,6 +76,7 @@ source_set("unit_tests") {
} }
source_set("eg_tests") { source_set("eg_tests") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
testonly = true testonly = true
sources = [ sources = [
...@@ -97,3 +98,30 @@ source_set("eg_tests") { ...@@ -97,3 +98,30 @@ source_set("eg_tests") {
] ]
libs = [ "XCTest.framework" ] 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 = [
"sad_tab_view_egtest.mm",
]
deps = [
"//components/strings",
"//ios/chrome/app/strings",
"//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/test:eg_test_support+eg2",
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/testing:embedded_test_server_support",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
"//ios/web/public/test/http_server",
"//ui/base",
]
libs = [ "UIKit.framework" ]
}
...@@ -2,16 +2,14 @@ ...@@ -2,16 +2,14 @@
// 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 <XCTest/XCTest.h>
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h" #import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/earl_grey/chrome_actions.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#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_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_grey/chrome_test_case.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_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
...@@ -24,53 +22,36 @@ namespace { ...@@ -24,53 +22,36 @@ namespace {
// Returns matcher that looks for text in UILabel, UITextView, and UITextField // Returns matcher that looks for text in UILabel, UITextView, and UITextField
// objects, checking if their displayed strings contain the provided |text|. // objects, checking if their displayed strings contain the provided |text|.
id<GREYMatcher> ContainsText(NSString* text) { id<GREYMatcher> ContainsText(NSString* text) {
MatchesBlock matches = ^BOOL(id element) { GREYMatchesBlock matches = ^BOOL(id element) {
return [[element text] containsString:text]; return [[element text] containsString:text];
}; };
DescribeToBlock describe = ^void(id<GREYDescription> description) { GREYDescribeToBlock describe = ^void(id<GREYDescription> description) {
[description appendText:[NSString stringWithFormat:@"hasText('%@')", text]]; [description appendText:[NSString stringWithFormat:@"hasText('%@')", text]];
}; };
id<GREYMatcher> matcher = id<GREYMatcher> matcher =
[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches [[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches
descriptionBlock:describe]; descriptionBlock:describe];
return grey_allOf(grey_anyOf(grey_kindOfClass([UILabel class]), return grey_allOf(grey_anyOf(grey_kindOfClassName(@"UILabel"),
grey_kindOfClass([UITextField class]), grey_kindOfClassName(@"UITextField"),
grey_kindOfClass([UITextView class]), nil), grey_kindOfClassName(@"UITextView"), nil),
matcher, nil); matcher, nil);
} }
// A matcher for the main title of the Sad Tab in 'reload' mode. // A matcher for the main title of the Sad Tab in 'reload' mode.
id<GREYMatcher> reloadSadTabTitleText() { id<GREYMatcher> reloadSadTabTitleText() {
static id matcher = nil; return ContainsText(l10n_util::GetNSString(IDS_SAD_TAB_MESSAGE));
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
matcher = [GREYMatchers
matcherForText:l10n_util::GetNSString(IDS_SAD_TAB_MESSAGE)];
});
return matcher;
} }
// A matcher for the main title of the Sad Tab in 'feedback' mode. // A matcher for the main title of the Sad Tab in 'feedback' mode.
id<GREYMatcher> feedbackSadTabTitleContainsText() { id<GREYMatcher> feedbackSadTabTitleContainsText() {
static id matcher = nil; return ContainsText(l10n_util::GetNSString(IDS_SAD_TAB_RELOAD_TRY));
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
matcher = ContainsText(l10n_util::GetNSString(IDS_SAD_TAB_RELOAD_TRY));
});
return matcher;
} }
// A matcher for a help string suggesting the user use Incognito Mode. // A matcher for a help string suggesting the user use Incognito Mode.
id<GREYMatcher> incognitoHelpContainsText() { id<GREYMatcher> incognitoHelpContainsText() {
static id matcher = nil; return ContainsText(l10n_util::GetNSString(IDS_SAD_TAB_RELOAD_INCOGNITO));
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
matcher =
ContainsText(l10n_util::GetNSString(IDS_SAD_TAB_RELOAD_INCOGNITO));
});
return matcher;
}
} }
} // namespace
// Sad Tab View integration tests for Chrome. // Sad Tab View integration tests for Chrome.
@interface SadTabViewTestCase : ChromeTestCase @interface SadTabViewTestCase : ChromeTestCase
......
...@@ -46,6 +46,7 @@ chrome_ios_eg2_test("ios_chrome_ui_eg2tests_module") { ...@@ -46,6 +46,7 @@ chrome_ios_eg2_test("ios_chrome_ui_eg2tests_module") {
"//ios/chrome/browser/ui/omnibox/popup/shortcuts:eg2_tests", "//ios/chrome/browser/ui/omnibox/popup/shortcuts:eg2_tests",
"//ios/chrome/browser/ui/open_in:eg2_tests", "//ios/chrome/browser/ui/open_in:eg2_tests",
"//ios/chrome/browser/ui/page_info:eg2_tests", "//ios/chrome/browser/ui/page_info:eg2_tests",
"//ios/chrome/browser/ui/sad_tab:eg2_tests",
"//ios/chrome/browser/ui/settings/autofill:eg2_tests", "//ios/chrome/browser/ui/settings/autofill:eg2_tests",
"//ios/chrome/browser/ui/toolbar:eg2_tests", "//ios/chrome/browser/ui/toolbar: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