Commit 7401a4eb authored by Peter K. Lee's avatar Peter K. Lee Committed by Commit Bot

Adds TranslateAppInterface to prepare for EG2 conversion

Use TranslateAppInterface to migrate EG1 tests to be EG2 compatible

Bug: None
Change-Id: Ide249041d5e35567f184df89b430a3c29f1e5bc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1967763
Commit-Queue: Peter Lee <pkl@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726715}
parent 35ac419d
...@@ -108,12 +108,14 @@ source_set("unit_tests") { ...@@ -108,12 +108,14 @@ 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 = [
"translate_egtest.mm", "translate_egtest.mm",
] ]
deps = [ deps = [
":test_support",
":translate", ":translate",
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
...@@ -132,6 +134,7 @@ source_set("eg_tests") { ...@@ -132,6 +134,7 @@ source_set("eg_tests") {
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support", "//ios/chrome/test/earl_grey:test_support",
"//ios/chrome/test/fakes", "//ios/chrome/test/fakes",
"//ios/testing/earl_grey:earl_grey_support",
"//ios/third_party/earl_grey:earl_grey+link", "//ios/third_party/earl_grey:earl_grey+link",
"//ios/web:earl_grey_test_support", "//ios/web:earl_grey_test_support",
"//ios/web/public/test", "//ios/web/public/test",
...@@ -141,3 +144,57 @@ source_set("eg_tests") { ...@@ -141,3 +144,57 @@ 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 = []
deps = []
libs = [ "UIKit.framework" ]
}
source_set("test_support") {
defines = [ "CHROME_EARL_GREY_1" ]
testonly = true
sources = [
"translate_app_interface.h",
"translate_app_interface.mm",
]
deps = [
"//components/translate/core/browser:browser",
"//components/translate/core/common:common",
"//components/translate/ios/browser:browser",
"//ios/chrome/browser/browser_state:browser_state",
"//ios/chrome/browser/translate",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/fakes:fakes",
]
configs += [ "//build/config/compiler:enable_arc" ]
}
source_set("eg_app_support+eg2") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = []
}
source_set("eg_test_support+eg2") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = []
deps = [
"//ios/testing/earl_grey:eg_test_support+eg2",
]
}
// 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_TRANSLATE_TRANSLATE_APP_INTERFACE_H_
#define IOS_CHROME_BROWSER_TRANSLATE_TRANSLATE_APP_INTERFACE_H_
#import <Foundation/Foundation.h>
@interface TranslateAppInterface : NSObject
// Sets up the app for testing.
+ (void)setUp;
// Tears down the testing set up for the app.
+ (void)tearDown;
// Registers an observer of the IOSLanguageDetectionTabHelper to capture
// the details of webpage language detection. The captured details can be
// used for test verification.
+ (void)setUpLanguageDetectionTabHelperObserver;
// Deallocates the observer for IOSLanguageDetectionTabHelper.
+ (void)tearDownLanguageDetectionTabHelperObserver;
// Resets the language detection state kept in the observer of
// IOSLanguageDetectionTabHelper.
+ (void)resetLanguageDetectionTabHelperObserver;
// Returns whether a language information was detected on the webpage.
+ (BOOL)isLanguageDetected;
// Returns the language code of the webpage indicated in the Content-Language
// HTTP header.
+ (NSString*)contentLanguage;
// Returns the language code indicated in the language attribute of the HTML
// element.
+ (NSString*)htmlRootLanguage;
// Returns the language code for the language determined from the webpage.
+ (NSString*)adoptedLanguage;
// Sets up a fake translation manager for the current WebState. This translation
// manager fakes the translation and does not depend on the real JavaScript.
+ (void)setUpFakeJSTranslateManagerInCurrentTab;
/// Whether user has set a preference to translate from |source| language to
// |target| language.
+ (BOOL)shouldAutoTranslateFromLanguage:(NSString*)source
toLanguage:(NSString*)target;
// Whether user has set a preference to block the translation of |language|.
+ (BOOL)isBlockedLanguage:(NSString*)language;
// Whether user has set a preference to translate any pages on |hostName|.
+ (BOOL)isBlockedSite:(NSString*)hostName;
@end
#endif // IOS_CHROME_BROWSER_TRANSLATE_TRANSLATE_APP_INTERFACE_H_
This diff is collapsed.
// 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/translate/translate_app_interface.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#if defined(CHROME_EARL_GREY_2)
// TODO(crbug.com/1015113): The EG2 macro is breaking indexing for some reason
// without the trailing semicolon. For now, disable the extra semi warning
// so Xcode indexing works for the egtest.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat-extra-semi"
GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(TranslateAppInterface);
#pragma clang diagnostic pop
#endif // defined(CHROME_EARL_GREY_2)
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