Commit 3c5026f4 authored by Peter K. Lee's avatar Peter K. Lee Committed by Commit Bot

Convert translate_egtest.mm to EG2

Reduce dependencies on Translate internals
- Refactored some constants out into their own targets
- Stopped using LanguageDetectionDetails where simple alternatives exist
- Use url.SchemeIs()
- Use executeJavaScript:error: from ChromeEarlGreyAppInterface
- TranslateAppInterface setUp needs to be passed switch for HttpServer

Bug: 987646
Change-Id: I4c47b9abca4a64d09a267b526dadc87cb10fe76b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1979768
Commit-Queue: Peter Lee <pkl@chromium.org>
Auto-Submit: Peter Lee <pkl@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727310}
parent 19d83c05
......@@ -125,11 +125,11 @@ source_set("eg_tests") {
"//components/translate/core/common",
"//components/translate/ios/browser",
"//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser",
"//ios/chrome/browser:chrome_url_constants",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/browser/ui/translate:legacy_translate",
"//ios/chrome/browser/ui/translate:translate_ui",
"//ios/chrome/browser/ui/translate:legacy_translate_constants",
"//ios/chrome/browser/ui/translate:translate_ui_constants",
"//ios/chrome/browser/ui/util:util",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
......@@ -152,8 +152,28 @@ source_set("eg2_tests") {
"//build/config/ios:xctest_config",
]
testonly = true
sources = []
deps = []
sources = [
"translate_egtest.mm",
]
deps = [
":eg_test_support+eg2",
"//base/test:test_support",
"//components/strings:components_strings_grit",
"//components/translate/core/browser:browser",
"//components/translate/core/common:common",
"//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser:chrome_url_constants",
"//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/browser/ui/translate:legacy_translate_constants",
"//ios/chrome/browser/ui/translate:translate_ui_constants",
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
"//ios/web/public:public",
"//ios/web/public/test/http_server:http_server",
"//ui/base:base",
"//url:url",
]
libs = [ "UIKit.framework" ]
}
......@@ -183,7 +203,21 @@ source_set("eg_app_support+eg2") {
"//build/config/ios:xctest_config",
]
testonly = true
sources = []
sources = [
"translate_app_interface.h",
"translate_app_interface.mm",
]
deps = [
"//base:base",
"//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:translate",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/fakes:fakes",
"//net:net",
]
}
source_set("eg_test_support+eg2") {
......@@ -193,8 +227,13 @@ source_set("eg_test_support+eg2") {
"//build/config/ios:xctest_config",
]
testonly = true
sources = []
sources = [
"translate_app_interface.h",
"translate_app_interface_stub.mm",
]
deps = [
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
]
}
......@@ -9,8 +9,9 @@
@interface TranslateAppInterface : NSObject
// Sets up the app for testing.
+ (void)setUp;
// Sets up the app for testing. |translateScriptServer| is the URL
// for the server that can serve up translate scripts to app.
+ (void)setUpWithScriptServer:(NSString*)translateScriptServerURL;
// Tears down the testing set up for the app.
+ (void)tearDown;
......@@ -56,6 +57,13 @@
// Whether user has set a preference to translate any pages on |hostName|.
+ (BOOL)isBlockedSite:(NSString*)hostName;
// The following are Translate Infobar UI constants. Test client needs to know
// to verify that Translate Infobar is behaving correctly.
+ (int)infobarAutoAlwaysThreshold;
+ (int)infobarAutoNeverThreshold;
+ (int)infobarMaximumNumberOfAutoAlways;
+ (int)infobarMaximumNumberOfAutoNever;
@end
#endif // IOS_CHROME_BROWSER_TRANSLATE_TRANSLATE_APP_INTERFACE_H_
......@@ -4,12 +4,15 @@
#import "ios/chrome/browser/translate/translate_app_interface.h"
#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "components/translate/core/browser/translate_infobar_delegate.h"
#include "components/translate/core/browser/translate_manager.h"
#include "components/translate/core/browser/translate_prefs.h"
#include "components/translate/core/common/language_detection_details.h"
#include "components/translate/core/common/translate_switches.h"
#import "components/translate/ios/browser/js_translate_manager.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/translate/chrome_ios_translate_client.h"
......@@ -161,7 +164,7 @@ class TranslateAppInterfaceHelper {
#pragma mark public methods
+ (void)setUp {
+ (void)setUpWithScriptServer:(NSString*)translateScriptServerURL {
// Allows the offering of translate in builds without an API key.
translate::TranslateManager::SetIgnoreMissingKeyForTesting(true);
[self setUpLanguageDetectionTabHelperObserver];
......@@ -169,6 +172,13 @@ class TranslateAppInterfaceHelper {
// Sets up a fake JsTranslateManager that does not use the translate script.
[self setUpFakeJSTranslateManagerInCurrentTab];
TranslateAppInterfaceHelper::GetInstance()->SetUpFakeWiFiConnection();
// Sets URL for the translate script to hit a HTTP server selected by
// the test app
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
command_line->AppendSwitchASCII(
translate::switches::kTranslateScriptURL,
base::SysNSStringToUTF8(translateScriptServerURL));
}
+ (void)tearDown {
......@@ -260,6 +270,22 @@ class TranslateAppInterfaceHelper {
return prefs->IsSiteBlacklisted(base::SysNSStringToUTF8(hostName));
}
+ (int)infobarAutoAlwaysThreshold {
return translate::TranslateInfoBarDelegate::GetAutoAlwaysThreshold();
}
+ (int)infobarAutoNeverThreshold {
return translate::TranslateInfoBarDelegate::GetAutoNeverThreshold();
}
+ (int)infobarMaximumNumberOfAutoAlways {
return translate::TranslateInfoBarDelegate::GetMaximumNumberOfAutoAlways();
}
+ (int)infobarMaximumNumberOfAutoNever {
return translate::TranslateInfoBarDelegate::GetMaximumNumberOfAutoNever();
}
#pragma mark private methods
// Reset translate prefs to default.
......
......@@ -12,20 +12,13 @@
#include "base/strings/utf_string_conversions.h"
#import "base/test/ios/wait_util.h"
#include "components/strings/grit/components_strings.h"
#include "components/translate/core/browser/translate_infobar_delegate.h"
#include "components/translate/core/browser/translate_pref_names.h"
#include "components/translate/core/browser/translate_prefs.h"
#include "components/translate/core/common/language_detection_details.h"
#include "components/translate/core/common/translate_constants.h"
#include "components/translate/core/common/translate_switches.h"
#import "components/translate/ios/browser/js_translate_manager.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/chrome_url_util.h"
#include "ios/chrome/browser/translate/chrome_ios_translate_client.h"
#include "ios/chrome/browser/chrome_url_constants.h"
#import "ios/chrome/browser/translate/translate_app_interface.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h"
#import "ios/chrome/browser/ui/translate/legacy_translate_infobar_coordinator.h"
#import "ios/chrome/browser/ui/translate/translate_infobar_view.h"
#import "ios/chrome/browser/ui/translate/legacy_translate_infobar_constants.h"
#import "ios/chrome/browser/ui/translate/translate_infobar_view_constants.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.h"
......@@ -36,7 +29,6 @@
#include "ios/web/public/test/http_server/data_response_provider.h"
#import "ios/web/public/test/http_server/http_server.h"
#include "ios/web/public/test/http_server/http_server_util.h"
#import "ios/web/public/web_state.h"
#include "net/base/url_util.h"
#include "ui/base/l10n/l10n_util_mac.h"
#include "url/gurl.h"
......@@ -243,7 +235,7 @@ bool TestResponseProvider::CanHandleRequest(const Request& request) {
url.path() == kFrenchPageNoTranslateContent ||
url.path() == kFrenchPageNoTranslateValue ||
url.path() == kTranslateScriptPath)) ||
UrlHasChromeScheme(url);
url.SchemeIs(kChromeUIScheme);
}
void TestResponseProvider::GetResponseHeadersAndBody(
......@@ -252,7 +244,7 @@ void TestResponseProvider::GetResponseHeadersAndBody(
std::string* response_body) {
const GURL& url = request.url;
*headers = web::ResponseProvider::GetDefaultResponseHeaders();
if (UrlHasChromeScheme(url)) {
if (url.SchemeIs(kChromeUIScheme)) {
*response_body = url.spec();
return;
} else if (url.path() == kLanguagePath) {
......@@ -338,14 +330,13 @@ void TestResponseProvider::GetLanguageResponse(
- (void)setUp {
[super setUp];
[TranslateAppInterface setUp];
// Set up a fake URL for the translate script to hit the mock HTTP server.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
// Set up the fake URL for the translate script to hit the mock HTTP server.
GURL translateScriptURL = web::test::HttpServer::MakeUrl(
base::StringPrintf("http://%s", kTranslateScriptPath));
command_line->AppendSwitchASCII(translate::switches::kTranslateScriptURL,
translateScriptURL.spec().c_str());
NSString* translateScriptSwitchValue =
base::SysUTF8ToNSString(translateScriptURL.spec());
[TranslateAppInterface setUpWithScriptServer:translateScriptSwitchValue];
}
- (void)tearDown {
......@@ -366,13 +357,11 @@ void TestResponseProvider::GetLanguageResponse(
GetFrenchPageHtml(kHtmlAttributeWithDeLang, kMetaItContentLanguage);
web::test::SetUpSimpleHttpServer(responses);
translate::LanguageDetectionDetails expectedLanguageDetails;
expectedLanguageDetails.content_language = "it";
expectedLanguageDetails.html_root_language = "de";
expectedLanguageDetails.adopted_language = translate::kUnknownLanguageCode;
[ChromeEarlGrey loadURL:URL];
[self assertLanguageDetails:expectedLanguageDetails];
[self assertContentLanguage:@"it"
htmlRootLanguage:@"de"
adoptedLanguage:base::SysUTF8ToNSString(
translate::kUnknownLanguageCode)];
}
// Tests that hidden text is not considered during detection.
......@@ -387,9 +376,10 @@ void TestResponseProvider::GetLanguageResponse(
[ChromeEarlGrey loadURL:URL];
// Check for no language detected.
translate::LanguageDetectionDetails expectedLanguageDetails;
expectedLanguageDetails.adopted_language = translate::kUnknownLanguageCode;
[self assertLanguageDetails:expectedLanguageDetails];
[self assertContentLanguage:@""
htmlRootLanguage:@""
adoptedLanguage:base::SysUTF8ToNSString(
translate::kUnknownLanguageCode)];
}
// Tests that language detection is not performed when the page specifies that
......@@ -430,21 +420,26 @@ void TestResponseProvider::GetLanguageResponse(
[ChromeEarlGrey loadURL:URL];
// Check for no language detected.
translate::LanguageDetectionDetails expectedLanguageDetails;
expectedLanguageDetails.adopted_language = "und";
[self assertLanguageDetails:expectedLanguageDetails];
[self assertContentLanguage:@""
htmlRootLanguage:@""
adoptedLanguage:base::SysUTF8ToNSString(
translate::kUnknownLanguageCode)];
// Resets state before triggering a new round of language detection.
[TranslateAppInterface resetLanguageDetectionTabHelperObserver];
// Change the text of the page.
chrome_test_util::ExecuteJavaScript(
[NSString stringWithFormat:@"document.write('%s');", kEnglishText], nil);
NSError* error = nil;
[ChromeEarlGreyAppInterface
executeJavaScript:[NSString stringWithFormat:@"document.write('%s');",
kEnglishText]
error:&error];
// Trigger a new detection with pushState.
chrome_test_util::ExecuteJavaScript(@"history.pushState(null, null, null);",
nil);
error = nil;
[ChromeEarlGreyAppInterface
executeJavaScript:@"history.pushState(null, null, null);"
error:&error];
// Check that the new language has been detected.
expectedLanguageDetails.adopted_language = "en";
[self assertLanguageDetails:expectedLanguageDetails];
[self assertContentLanguage:@"" htmlRootLanguage:@"" adoptedLanguage:@"en"];
}
// Tests that language detection is performed on hash changes.
......@@ -472,17 +467,14 @@ void TestResponseProvider::GetLanguageResponse(
[ChromeEarlGrey loadURL:URL];
// Check that language has been detected.
translate::LanguageDetectionDetails expectedLanguageDetails;
expectedLanguageDetails.adopted_language = "fr";
[self assertLanguageDetails:expectedLanguageDetails];
[self assertContentLanguage:@"" htmlRootLanguage:@"" adoptedLanguage:@"fr"];
// Resets state before triggering a new round of language detection.
[TranslateAppInterface resetLanguageDetectionTabHelperObserver];
// Trigger the hash change.
[ChromeEarlGrey tapWebStateElementWithID:@"Hash"];
// Check that language detection has been re-run.
expectedLanguageDetails.adopted_language = "en";
[self assertLanguageDetails:expectedLanguageDetails];
[self assertContentLanguage:@"" htmlRootLanguage:@"" adoptedLanguage:@"en"];
}
// Tests that language in http content is detected.
......@@ -495,10 +487,7 @@ void TestResponseProvider::GetLanguageResponse(
GURL URL = web::test::HttpServer::MakeUrl(std::string("http://") +
kLanguagePath + "?http=fr");
[ChromeEarlGrey loadURL:URL];
translate::LanguageDetectionDetails expectedLanguageDetails;
expectedLanguageDetails.content_language = "fr";
expectedLanguageDetails.adopted_language = "fr";
[self assertLanguageDetails:expectedLanguageDetails];
[self assertContentLanguage:@"fr" htmlRootLanguage:@"" adoptedLanguage:@"fr"];
// Resets state before triggering a new round of language detection.
[TranslateAppInterface resetLanguageDetectionTabHelperObserver];
......@@ -506,9 +495,7 @@ void TestResponseProvider::GetLanguageResponse(
URL = web::test::HttpServer::MakeUrl(std::string("http://") + kLanguagePath +
"?http=fr,ornot");
[ChromeEarlGrey loadURL:URL];
expectedLanguageDetails.content_language = "fr";
expectedLanguageDetails.adopted_language = "fr";
[self assertLanguageDetails:expectedLanguageDetails];
[self assertContentLanguage:@"fr" htmlRootLanguage:@"" adoptedLanguage:@"fr"];
// Resets state before triggering a new round of language detection.
[TranslateAppInterface resetLanguageDetectionTabHelperObserver];
......@@ -516,9 +503,7 @@ void TestResponseProvider::GetLanguageResponse(
URL = web::test::HttpServer::MakeUrl(std::string("http://") + kLanguagePath +
"?http=fr&meta=it");
[ChromeEarlGrey loadURL:URL];
expectedLanguageDetails.content_language = "it";
expectedLanguageDetails.adopted_language = "it";
[self assertLanguageDetails:expectedLanguageDetails];
[self assertContentLanguage:@"it" htmlRootLanguage:@"" adoptedLanguage:@"it"];
// Resets state before triggering a new round of language detection.
[TranslateAppInterface resetLanguageDetectionTabHelperObserver];
......@@ -526,9 +511,7 @@ void TestResponseProvider::GetLanguageResponse(
URL =
web::test::HttpServer::MakeUrl(std::string("http://") + kSubresourcePath);
[ChromeEarlGrey loadURL:URL];
expectedLanguageDetails.content_language = "fr";
expectedLanguageDetails.adopted_language = "fr";
[self assertLanguageDetails:expectedLanguageDetails];
[self assertContentLanguage:@"fr" htmlRootLanguage:@"" adoptedLanguage:@"fr"];
}
// Tests that language in http content is detected when navigating to a link.
......@@ -546,10 +529,7 @@ void TestResponseProvider::GetLanguageResponse(
[[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
someLanguageURL.GetContent())]
assertWithMatcher:grey_notNil()];
translate::LanguageDetectionDetails expectedLanguageDetails;
expectedLanguageDetails.content_language = "es";
expectedLanguageDetails.adopted_language = "es";
[self assertLanguageDetails:expectedLanguageDetails];
[self assertContentLanguage:@"es" htmlRootLanguage:@"" adoptedLanguage:@"es"];
}
// Tests that language detection still happens when a very large quantity of
......@@ -574,10 +554,7 @@ void TestResponseProvider::GetLanguageResponse(
[ChromeEarlGrey loadURL:URL];
// Check that language has been detected.
translate::LanguageDetectionDetails expectedLanguageDetails;
expectedLanguageDetails.html_root_language = "fr";
expectedLanguageDetails.adopted_language = "fr";
[self assertLanguageDetails:expectedLanguageDetails];
[self assertContentLanguage:@"" htmlRootLanguage:@"fr" adoptedLanguage:@"fr"];
}
// Tests that language detection is not performed when translate is disabled.
......@@ -1018,8 +995,7 @@ void TestResponseProvider::GetLanguageResponse(
// Translate the page by tapping the target language tab until
// "Always Translate" is automatically triggered.
for (int i = 0;
i <= translate::TranslateInfoBarDelegate::GetAutoAlwaysThreshold();
for (int i = 0; i <= [TranslateAppInterface infobarAutoAlwaysThreshold];
i++) {
[[EarlGrey
selectElementWithMatcher:ButtonWithAccessibilityLabel(@"English")]
......@@ -1068,13 +1044,11 @@ void TestResponseProvider::GetLanguageResponse(
@"French to English translation is automatic");
// Trigger and refuse the auto "Always Translate".
for (int i = 0;
i < translate::TranslateInfoBarDelegate::GetMaximumNumberOfAutoAlways();
for (int i = 0; i < [TranslateAppInterface infobarMaximumNumberOfAutoAlways];
i++) {
// Translate the page by tapping the target language tab until
// "Always Translate" is automatically triggered.
for (int j = 0;
j <= translate::TranslateInfoBarDelegate::GetAutoAlwaysThreshold();
for (int j = 0; j <= [TranslateAppInterface infobarAutoAlwaysThreshold];
j++) {
[[EarlGrey
selectElementWithMatcher:ButtonWithAccessibilityLabel(@"English")]
......@@ -1089,8 +1063,7 @@ void TestResponseProvider::GetLanguageResponse(
// Translate the page by tapping the target language tab in order to
// automatically trigger "Always Translate".
for (int i = 0;
i <= translate::TranslateInfoBarDelegate::GetAutoAlwaysThreshold();
for (int i = 0; i <= [TranslateAppInterface infobarAutoAlwaysThreshold];
i++) {
[[EarlGrey
selectElementWithMatcher:ButtonWithAccessibilityLabel(@"English")]
......@@ -1200,8 +1173,7 @@ void TestResponseProvider::GetLanguageResponse(
// Dismiss the translate infobar until "Never Translate ..." is automatically
// triggered.
for (int i = 0;
i < translate::TranslateInfoBarDelegate::GetAutoNeverThreshold(); i++) {
for (int i = 0; i < [TranslateAppInterface infobarAutoNeverThreshold]; i++) {
// Reload the page.
[ChromeEarlGrey reload];
......@@ -1255,13 +1227,11 @@ void TestResponseProvider::GetLanguageResponse(
@"Translation from French is blocked");
// Trigger and refuse the auto "Never Translate ...".
for (int i = 0;
i < translate::TranslateInfoBarDelegate::GetMaximumNumberOfAutoNever();
for (int i = 0; i < [TranslateAppInterface infobarMaximumNumberOfAutoNever];
i++) {
// Dismiss the translate infobar until "Never Translate ..." is
// automatically triggered.
for (int j = 0;
j < translate::TranslateInfoBarDelegate::GetAutoNeverThreshold();
for (int j = 0; j < [TranslateAppInterface infobarAutoNeverThreshold];
j++) {
// Reload the page.
[ChromeEarlGrey reload];
......@@ -1282,8 +1252,7 @@ void TestResponseProvider::GetLanguageResponse(
// Dismiss the translate infobar in order to automatically trigger
// "Never Translate ...".
for (int i = 0;
i < translate::TranslateInfoBarDelegate::GetAutoNeverThreshold(); i++) {
for (int i = 0; i < [TranslateAppInterface infobarAutoNeverThreshold]; i++) {
// Reload the page.
[ChromeEarlGrey reload];
......@@ -1666,39 +1635,35 @@ void TestResponseProvider::GetLanguageResponse(
return detected;
}
// Waits until language details have been detected then verifies them. Resets
// language details in order to wait for new detection in the next call.
- (void)assertLanguageDetails:
(const translate::LanguageDetectionDetails&)expectedDetails {
GREYAssert([self waitForLanguageDetection],
@"Language not detected");
// Waits until language details have been detected then verifies them.
// Checks expectation for Content-Language, HTML root element language, and
// detected language on page. Use @"" for expected values that are expected
// to be not set.
- (void)assertContentLanguage:(NSString*)expectedContentLanguage
htmlRootLanguage:(NSString*)expectedHtmlRootLanguage
adoptedLanguage:(NSString*)expectedAdoptedLanguage {
GREYAssert([self waitForLanguageDetection], @"Language not detected");
std::string contentLanguage =
base::SysNSStringToUTF8([TranslateAppInterface contentLanguage]);
NSString* contentLanguage = [TranslateAppInterface contentLanguage];
NSString* contentLanguageError =
[NSString stringWithFormat:@"Wrong content-language: %s (expected %s)",
contentLanguage.c_str(),
expectedDetails.content_language.c_str()];
GREYAssertEqual(expectedDetails.content_language, contentLanguage,
contentLanguageError);
std::string htmlRootLanguage =
base::SysNSStringToUTF8([TranslateAppInterface htmlRootLanguage]);
[NSString stringWithFormat:@"Wrong content-language: %@ (expected %@)",
contentLanguage, expectedContentLanguage];
GREYAssertEqualObjects(expectedContentLanguage, contentLanguage,
contentLanguageError);
NSString* htmlRootLanguage = [TranslateAppInterface htmlRootLanguage];
NSString* htmlRootLanguageError =
[NSString stringWithFormat:@"Wrong html root language: %s (expected %s)",
htmlRootLanguage.c_str(),
expectedDetails.html_root_language.c_str()];
GREYAssertEqual(expectedDetails.html_root_language, htmlRootLanguage,
htmlRootLanguageError);
std::string adoptedLanguage =
base::SysNSStringToUTF8([TranslateAppInterface adoptedLanguage]);
[NSString stringWithFormat:@"Wrong html root language: %@ (expected %@)",
htmlRootLanguage, expectedHtmlRootLanguage];
GREYAssertEqualObjects(expectedHtmlRootLanguage, htmlRootLanguage,
htmlRootLanguageError);
NSString* adoptedLanguage = [TranslateAppInterface adoptedLanguage];
NSString* adoptedLanguageError =
[NSString stringWithFormat:@"Wrong adopted language: %s (expected %s)",
adoptedLanguage.c_str(),
expectedDetails.adopted_language.c_str()];
GREYAssertEqual(expectedDetails.adopted_language, adoptedLanguage,
adoptedLanguageError);
[NSString stringWithFormat:@"Wrong adopted language: %@ (expected %@)",
adoptedLanguage, expectedAdoptedLanguage];
GREYAssertEqualObjects(expectedAdoptedLanguage, adoptedLanguage,
adoptedLanguageError);
}
@end
......@@ -11,6 +11,7 @@ source_set("legacy_translate") {
"legacy_translate_infobar_mediator.mm",
]
deps = [
":legacy_translate_constants",
":translate_ui",
"//base",
"//components/strings:components_strings_grit",
......@@ -30,6 +31,14 @@ source_set("legacy_translate") {
]
}
source_set("legacy_translate_constants") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"legacy_translate_infobar_constants.h",
"legacy_translate_infobar_constants.mm",
]
}
source_set("translate_ui") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
......@@ -48,6 +57,7 @@ source_set("translate_ui") {
"translate_notification_presenter.mm",
]
deps = [
":translate_ui_constants",
"//base",
"//components/strings:components_strings",
"//ios/chrome/app/strings:ios_strings_grit",
......@@ -70,6 +80,14 @@ source_set("translate_ui") {
]
}
source_set("translate_ui_constants") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"translate_infobar_view_constants.h",
"translate_infobar_view_constants.mm",
]
}
source_set("unit_tests") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
......
// 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_TRANSLATE_LEGACY_TRANSLATE_INFOBAR_CONSTANTS_H_
#define IOS_CHROME_BROWSER_UI_TRANSLATE_LEGACY_TRANSLATE_INFOBAR_CONSTANTS_H_
#import <UIKit/UIKit.h>
// The a11y identifier for the translate infobar's language selection menu.
extern NSString* const kLanguageSelectorPopupMenuId;
// The a11y identifier for the translate infobar's translate options menu.
extern NSString* const kTranslateOptionsPopupMenuId;
#endif // IOS_CHROME_BROWSER_UI_TRANSLATE_LEGACY_TRANSLATE_INFOBAR_CONSTANTS_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/translate/legacy_translate_infobar_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
NSString* const kLanguageSelectorPopupMenuId = @"kLanguageSelectorPopupMenuId";
NSString* const kTranslateOptionsPopupMenuId = @"kTranslateOptionsPopupMenuId";
......@@ -9,11 +9,6 @@
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
// The a11y identifier for the translate infobar's language selection menu.
extern NSString* const kLanguageSelectorPopupMenuId;
// The a11y identifier for the translate infobar's translate options menu.
extern NSString* const kTranslateOptionsPopupMenuId;
@protocol SnackbarCommands;
class WebStateList;
......
......@@ -19,6 +19,7 @@
#import "ios/chrome/browser/ui/popup_menu/public/popup_menu_table_view_controller_delegate.h"
#import "ios/chrome/browser/ui/popup_menu/public/popup_menu_ui_constants.h"
#import "ios/chrome/browser/ui/translate/cells/select_language_popup_menu_item.h"
#import "ios/chrome/browser/ui/translate/legacy_translate_infobar_constants.h"
#import "ios/chrome/browser/ui/translate/legacy_translate_infobar_mediator.h"
#import "ios/chrome/browser/ui/translate/translate_notification_presenter.h"
#import "ios/chrome/browser/ui/util/layout_guide_names.h"
......@@ -27,9 +28,6 @@
#error "This file requires ARC support."
#endif
NSString* const kLanguageSelectorPopupMenuId = @"kLanguageSelectorPopupMenuId";
NSString* const kTranslateOptionsPopupMenuId = @"kTranslateOptionsPopupMenuId";
@interface LegacyTranslateInfobarCoordinator () <
LanguageSelectionHandler,
PopupMenuPresenterDelegate,
......
......@@ -6,7 +6,7 @@
#import "ios/chrome/browser/ui/translate/translate_infobar_language_tab_strip_view_delegate.h"
#import "ios/chrome/browser/ui/translate/translate_infobar_language_tab_view_delegate.h"
#import "ios/chrome/browser/ui/translate/translate_infobar_view.h"
#import "ios/chrome/browser/ui/translate/translate_infobar_view_constants.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......
......@@ -16,12 +16,6 @@ typedef NS_ENUM(NSInteger, TranslateInfobarViewState) {
TranslateInfobarViewStateAfterTranslate,
};
// Height of the infobar.
extern const CGFloat kInfobarHeight;
// The a11y identifier for the translate infobar view.
extern NSString* const kTranslateInfobarViewId;
@protocol TranslateInfobarViewDelegate;
// An infobar for translating the page. Starting from the leading edge, it
......
......@@ -15,6 +15,7 @@
#import "ios/chrome/browser/ui/toolbar/public/toolbar_constants.h"
#import "ios/chrome/browser/ui/translate/translate_infobar_language_tab_strip_view.h"
#import "ios/chrome/browser/ui/translate/translate_infobar_language_tab_strip_view_delegate.h"
#import "ios/chrome/browser/ui/translate/translate_infobar_view_constants.h"
#import "ios/chrome/browser/ui/translate/translate_infobar_view_delegate.h"
#import "ios/chrome/browser/ui/util/label_link_controller.h"
#import "ios/chrome/browser/ui/util/layout_guide_names.h"
......@@ -30,10 +31,6 @@
#error "This file requires ARC support."
#endif
const CGFloat kInfobarHeight = 54;
NSString* const kTranslateInfobarViewId = @"kTranslateInfobarViewId";
namespace {
// Size of the infobar buttons.
......
// 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_TRANSLATE_TRANSLATE_INFOBAR_VIEW_CONSTANTS_H_
#define IOS_CHROME_BROWSER_UI_TRANSLATE_TRANSLATE_INFOBAR_VIEW_CONSTANTS_H_
#import <UIKit/UIKit.h>
// Height of the infobar.
extern const CGFloat kInfobarHeight;
// The a11y identifier for the translate infobar view.
extern NSString* const kTranslateInfobarViewId;
#endif // IOS_CHROME_BROWSER_UI_TRANSLATE_TRANSLATE_INFOBAR_VIEW_CONSTANTS_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/translate/translate_infobar_view_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
const CGFloat kInfobarHeight = 54;
NSString* const kTranslateInfobarViewId = @"kTranslateInfobarViewId";
......@@ -377,6 +377,7 @@ source_set("eg_app_support+eg2") {
"//ios/chrome/browser/ntp:features",
"//ios/chrome/browser/passwords",
"//ios/chrome/browser/passwords:eg_app_support+eg2",
"//ios/chrome/browser/translate:eg_app_support+eg2",
"//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/browser/ui/authentication:eg_app_support+eg2",
"//ios/chrome/browser/ui/authentication/cells",
......
......@@ -52,6 +52,7 @@ chrome_ios_eg2_test("ios_chrome_integration_eg2tests_module") {
"//ios/chrome/browser/ntp_tiles:eg2_tests",
"//ios/chrome/browser/passwords:eg2_tests",
"//ios/chrome/browser/prerender:eg2_tests",
"//ios/chrome/browser/translate:eg2_tests",
"//ios/chrome/browser/ui/autofill:eg2_tests",
"//ios/chrome/browser/ui/autofill/manual_fill:eg2_tests",
"//ios/chrome/browser/ui/content_suggestions: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