Commit 8f4964b6 authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Translate Messages EGTest

This creates an EG2 test suite for Translate for the new Messages UI.
Many tests are either direct copies or similar to those found in
TranslateTestCase. Some of them were also not moved over, because they
do not apply to the new Messages design.

Bug: 1014959
Change-Id: I4df264e6dcfabcdc7ad3933aeb43f2bb255c3d0b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036371
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738305}
parent dd381a1b
......@@ -142,14 +142,33 @@ source_set("eg2_tests") {
"//build/config/ios:xctest_config",
]
testonly = true
sources = [ "infobar_egtest.mm" ]
sources = [
"infobar_egtest.mm",
"translate_infobar_egtest.mm",
]
deps = [
":eg_test_support+eg2",
"//base",
"//base/test:test_support",
"//components/infobars/core:feature_flags",
"//components/strings:components_strings_grit",
"//components/translate/core/browser:translate_pref_names",
"//components/translate/core/common",
"//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser:chrome_url_constants",
"//ios/chrome/browser/translate:eg_test_support+eg2",
"//ios/chrome/browser/ui/badges:public",
"//ios/chrome/browser/ui/infobars:constants",
"//ios/chrome/browser/ui/infobars:feature_flags",
"//ios/chrome/browser/ui/infobars/banners:public",
"//ios/chrome/browser/ui/infobars/modals:public",
"//ios/chrome/browser/ui/popup_menu: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/test/http_server",
"//net",
"//ui/base",
"//url",
]
libs = [ "UIKit.framework" ]
......
......@@ -4,4 +4,7 @@ specific_include_rules = {
"infobar_egtest\.mm": [
"+ios/web/public/test/http_server",
],
}
"translate_infobar_egtest\.mm": [
"+ios/web/public/test/http_server",
],
}
\ No newline at end of file
......@@ -46,5 +46,7 @@ source_set("public") {
sources = [
"infobar_modal_constants.h",
"infobar_modal_constants.mm",
"infobar_translate_modal_constants.h",
"infobar_translate_modal_constants.mm",
]
}
......@@ -7,6 +7,7 @@
#include "base/strings/sys_string_conversions.h"
#include "components/translate/core/browser/translate_infobar_delegate.h"
#import "ios/chrome/browser/ui/infobars/modals/infobar_translate_language_selection_delegate.h"
#import "ios/chrome/browser/ui/infobars/modals/infobar_translate_modal_constants.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_item.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h"
......@@ -58,7 +59,8 @@ typedef NS_ENUM(NSInteger, SectionIdentifier) {
self.tableView.sectionHeaderHeight = 0;
[self.tableView
setSeparatorInset:UIEdgeInsetsMake(0, kTableViewHorizontalSpacing, 0, 0)];
self.tableView.accessibilityIdentifier =
kTranslateInfobarLanguageSelectionTableViewAXId;
[self loadModel];
}
......
// Copyright 2020 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_INFOBARS_MODALS_INFOBAR_TRANSLATE_MODAL_CONSTANTS_H_
#define IOS_CHROME_BROWSER_UI_INFOBARS_MODALS_INFOBAR_TRANSLATE_MODAL_CONSTANTS_H_
#import <UIKit/UIKit.h>
// Accessibility identifier of the Translate Language Selection Modal Table
// View.
extern NSString* const kTranslateInfobarLanguageSelectionTableViewAXId;
// Accessibility identifier of the Translate Infobar Modal Source Language item.
extern NSString* const kTranslateInfobarModalTranslateSourceLanguageItemAXId;
// Accessibility identifier of the Translate Infobar Modal Target Language item.
extern NSString* const kTranslateInfobarModalTranslateTargetLanguageItemAXId;
// Accessibility identifier of the Translate Infobar Modal Translate Button.
extern NSString* const kTranslateInfobarModalTranslateButtonAXId;
// Accessibility identifier of the Translate Infobar Modal Show Original Button.
extern NSString* const kTranslateInfobarModalShowOriginalButtonAXId;
// Accessibility identifier of the Translate Infobar Modal Always Translate
// Button.
extern NSString* const kTranslateInfobarModalAlwaysTranslateButtonAXId;
// Accessibility identifier of the Translate Infobar Modal Never Translate
// Button.
extern NSString* const kTranslateInfobarModalNeverTranslateButtonAXId;
// Accessibility identifier of the Translate Infobar Modal Never Translate Site
// Button.
extern NSString* const kTranslateInfobarModalNeverTranslateSiteButtonAXId;
#endif // IOS_CHROME_BROWSER_UI_INFOBARS_MODALS_INFOBAR_TRANSLATE_MODAL_CONSTANTS_H_
// Copyright 2020 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/infobars/modals/infobar_translate_modal_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
NSString* const kTranslateInfobarLanguageSelectionTableViewAXId =
@"kTranslateInfobarLanguageSelectionTableViewAXId";
NSString* const kTranslateInfobarModalTranslateSourceLanguageItemAXId =
@"kTranslateInfobarModalTranslateSourceLanguageItemAXId";
NSString* const kTranslateInfobarModalTranslateTargetLanguageItemAXId =
@"kTranslateInfobarModalTranslateTargetLanguageItemAXId";
NSString* const kTranslateInfobarModalTranslateButtonAXId =
@"kTranslateInfobarModalTranslateButtonAXId";
NSString* const kTranslateInfobarModalShowOriginalButtonAXId =
@"kTranslateInfobarModalShowOriginalButtonAXId";
NSString* const kTranslateInfobarModalAlwaysTranslateButtonAXId =
@"kTranslateInfobarModalAlwaysTranslateButtonAXId";
NSString* const kTranslateInfobarModalNeverTranslateButtonAXId =
@"kTranslateInfobarModalNeverTranslateButtonAXId";
NSString* const kTranslateInfobarModalNeverTranslateSiteButtonAXId =
@"kTranslateInfobarModalNeverTranslateSiteButtonAXId";
......@@ -7,6 +7,7 @@
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#import "ios/chrome/browser/ui/infobars/modals/infobar_modal_constants.h"
#import "ios/chrome/browser/ui/infobars/modals/infobar_translate_modal_constants.h"
#import "ios/chrome/browser/ui/infobars/modals/infobar_translate_modal_delegate.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_button_item.h"
......@@ -129,6 +130,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
l10n_util::GetNSString(
IDS_IOS_TRANSLATE_INFOBAR_MODAL_SOURCE_LANGUAGE_FIELD_NAME)
textFieldValue:self.sourceLanguage];
sourceLanguageItem.accessibilityIdentifier =
kTranslateInfobarModalTranslateSourceLanguageItemAXId;
[model addItem:sourceLanguageItem
toSectionWithIdentifier:SectionIdentifierContent];
......@@ -138,6 +141,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
l10n_util::GetNSString(
IDS_IOS_TRANSLATE_INFOBAR_MODAL_TARGET_LANGUAGE_FIELD_NAME)
textFieldValue:self.targetLanguage];
targetLanguageItem.accessibilityIdentifier =
kTranslateInfobarModalTranslateTargetLanguageItemAXId;
[model addItem:targetLanguageItem
toSectionWithIdentifier:SectionIdentifierContent];
......@@ -146,6 +151,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
buttonText:l10n_util::GetNSString(
IDS_IOS_TRANSLATE_INFOBAR_TRANSLATE_ACTION)];
translateButtonItem.disableButtonIntrinsicWidth = YES;
translateButtonItem.buttonAccessibilityIdentifier =
kTranslateInfobarModalTranslateButtonAXId;
if (!self.enableTranslateActionButton) {
translateButtonItem.buttonBackgroundColor =
[UIColor colorNamed:kDisabledTintColor];
......@@ -161,6 +168,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
IDS_IOS_TRANSLATE_INFOBAR_TRANSLATE_UNDO_ACTION)];
showOriginalButtonItem.buttonTextColor = [UIColor colorNamed:kBlueColor];
showOriginalButtonItem.buttonBackgroundColor = [UIColor clearColor];
showOriginalButtonItem.buttonAccessibilityIdentifier =
kTranslateInfobarModalShowOriginalButtonAXId;
[model addItem:showOriginalButtonItem
toSectionWithIdentifier:SectionIdentifierContent];
}
......@@ -170,6 +179,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
buttonText:[self shouldAlwaysTranslateButtonText]];
alwaysTranslateSourceItem.buttonTextColor = [UIColor colorNamed:kBlueColor];
alwaysTranslateSourceItem.buttonBackgroundColor = [UIColor clearColor];
alwaysTranslateSourceItem.buttonAccessibilityIdentifier =
kTranslateInfobarModalAlwaysTranslateButtonAXId;
[model addItem:alwaysTranslateSourceItem
toSectionWithIdentifier:SectionIdentifierContent];
......@@ -179,6 +190,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
buttonText:[self shouldNeverTranslateSourceButtonText]];
neverTranslateSourceItem.buttonTextColor = [UIColor colorNamed:kBlueColor];
neverTranslateSourceItem.buttonBackgroundColor = [UIColor clearColor];
neverTranslateSourceItem.buttonAccessibilityIdentifier =
kTranslateInfobarModalNeverTranslateButtonAXId;
[model addItem:neverTranslateSourceItem
toSectionWithIdentifier:SectionIdentifierContent];
}
......@@ -189,6 +202,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
buttonText:[self shouldNeverTranslateSiteButtonText]];
neverTranslateSiteItem.buttonTextColor = [UIColor colorNamed:kBlueColor];
neverTranslateSiteItem.buttonBackgroundColor = [UIColor clearColor];
neverTranslateSiteItem.buttonAccessibilityIdentifier =
kTranslateInfobarModalNeverTranslateSiteButtonAXId;
[model addItem:neverTranslateSiteItem
toSectionWithIdentifier:SectionIdentifierContent];
}
......
This diff is collapsed.
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