Commit 1690a76d authored by Tina Wang's avatar Tina Wang Committed by Commit Bot

[ios] Check the click action of default search engine managed UI

Check the click action of default search engine managed UI in EG test.

Test scenario:
1. Set the DefaultSearchProviderEnabled policy to false.
2. Open settings menu.
3. Click on the info button of search engine item.
4. Check if the enterprise info bubble has popped up.
5. Click outside of the bubble.
6. Check if the enterprise info bubble is hidden.

Bug: 1131052
Change-Id: Iadf059b54d9bc06ef191e6fb99ea393f46d7fecc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2425064
Commit-Queue: Tina Wang <tinazwang@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811302}
parent 2a31a15e
......@@ -175,6 +175,9 @@ source_set("eg2_tests") {
"//ios/chrome/browser:utils",
"//ios/chrome/browser/translate:eg_test_support+eg2",
"//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/browser/ui/settings:constants",
"//ios/chrome/browser/ui/settings/elements:constants",
"//ios/chrome/browser/ui/table_view/cells:cells_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",
......
......@@ -14,6 +14,9 @@
#include "ios/chrome/browser/pref_names.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/settings/elements/elements_constants.h"
#import "ios/chrome/browser/ui/settings/settings_table_view_controller_constants.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#include "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_matchers.h"
......@@ -121,11 +124,34 @@ id<GREYMatcher> ToolsMenuTranslateButton() {
}
// Tests for the DefaultSearchProviderEnabled policy.
// 1. Test if the policy can be properly set.
// 2. Test the managed UI item and clicking action.
- (void)testDefaultSearchProviderEnabled {
// Disable default search provider via policy and make sure it does not crash
// the omnibox UI.
SetPolicy(false, policy::key::kDefaultSearchProviderEnabled);
[ChromeEarlGrey loadURL:GURL("chrome://policy")];
[EarlGrey dismissKeyboardWithError:nil];
// Open settings menu and check if the settings UI is a managed UI.
[ChromeEarlGreyUI openSettingsMenu];
// Click on the info button of the managed item.
[ChromeEarlGreyUI tapSettingsMenuButton:grey_accessibilityID(
kTableViewCellInfoButtonViewId)];
// Check if the contextual bubble is shown.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kEnterpriseInfoBubbleViewId)]
assertWithMatcher:grey_sufficientlyVisible()];
// Tap outside of the bubble.
[[EarlGrey selectElementWithMatcher:chrome_test_util::SettingsDoneButton()]
performAction:grey_tap()];
// Check if the contextual bubble is hidden.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kEnterpriseInfoBubbleViewId)]
assertWithMatcher:grey_notVisible()];
}
// Tests for the PasswordManagerEnabled policy.
......
......@@ -15,6 +15,7 @@ source_set("enterprise_info_popover_view_controller") {
frameworks = [ "UIKit.framework" ]
deps = [
":constants",
"//base:base",
"//ios/chrome/app/strings",
"//ios/chrome/common:common",
......@@ -24,3 +25,11 @@ source_set("enterprise_info_popover_view_controller") {
"//ui/base",
]
}
source_set("constants") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"elements_constants.h",
"elements_constants.mm",
]
}
// 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_SETTINGS_ELEMENTS_ELEMENTS_CONSTANTS_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_ELEMENTS_ELEMENTS_CONSTANTS_H_
#import <Foundation/Foundation.h>
// The accessibility identifier of the enterpise info bubble view.
extern NSString* const kEnterpriseInfoBubbleViewId;
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_ELEMENTS_ELEMENTS_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/settings/elements/elements_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
NSString* const kEnterpriseInfoBubbleViewId = @"kEnterpriseInfoBubbleViewId";
......@@ -6,6 +6,7 @@
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#import "ios/chrome/browser/ui/settings/elements/elements_constants.h"
#import "ios/chrome/common/string_util.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
#import "ios/chrome/common/ui/elements/popover_label_view_controller.h"
......@@ -102,6 +103,13 @@ NSAttributedString* SecondaryMessage(NSString* enterpriseName) {
secondaryAttributedString:SecondaryMessage(enterpriseName)];
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.accessibilityIdentifier = kEnterpriseInfoBubbleViewId;
}
#pragma mark - UIPopoverPresentationControllerDelegate
- (void)popoverPresentationControllerDidDismissPopover:
......
......@@ -50,4 +50,8 @@ extern const CGFloat kTableViewAccessoryWidth;
// A masked password string(e.g. "••••••••").
extern NSString* const kMaskedPassword;
// The accessibility identifier of the info button of the
// TableViewInfoButtonCell.
extern NSString* const kTableViewCellInfoButtonViewId;
#endif // IOS_CHROME_BROWSER_UI_TABLE_VIEW_CELLS_TABLE_VIEW_CELLS_CONSTANTS_H_
......@@ -23,3 +23,5 @@ const CGFloat kTableViewLabelVerticalTopSpacing = 13.0;
const CGFloat kTableViewAccessoryWidth = 40;
NSString* const kMaskedPassword = @"••••••••";
NSString* const kTableViewCellInfoButtonViewId =
@"kTableViewCellInfoButtonViewId";
......@@ -6,6 +6,7 @@
#import "ios/chrome/browser/ui/settings/cells/settings_cells_constants.h"
#include "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
......@@ -108,6 +109,7 @@ const CGFloat kCellLabelsWidthProportion = 0.2f;
setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh + 1
forAxis:
UILayoutConstraintAxisHorizontal];
_trailingButton.accessibilityIdentifier = kTableViewCellInfoButtonViewId;
[self.contentView addSubview:_trailingButton];
// Set up the constraints assuming that the icon image is hidden.
......
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