Commit d3708f20 authored by edchin's avatar edchin Committed by Commit Bot

[ios] Create UI test for page info (site info)

This CL creates an UI integration test that tests that the
page info view gets automatically dismissed on device rotation.

Change-Id: I02611cc2fab5a214b74af01d15cd8d12e19eff6e
Reviewed-on: https://chromium-review.googlesource.com/c/1338561
Commit-Queue: edchin <edchin@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608844}
parent 6b499335
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
source_set("page_info") { source_set("page_info") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
"page_info_constants.h",
"page_info_constants.mm",
"page_info_model.cc", "page_info_model.cc",
"page_info_model.h", "page_info_model.h",
"page_info_model_observer.h", "page_info_model_observer.h",
...@@ -58,3 +60,20 @@ source_set("coordinator") { ...@@ -58,3 +60,20 @@ source_set("coordinator") {
] ]
libs = [ "UIKit.framework" ] libs = [ "UIKit.framework" ]
} }
source_set("eg_tests") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"page_info_egtest.mm",
]
deps = [
":page_info",
"//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/test/earl_grey:test_support",
]
libs = [
"UIKit.framework",
"XCTest.framework",
]
}
// Copyright 2018 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_PAGE_INFO_PAGE_INFO_CONSTANTS_H_
#define IOS_CHROME_BROWSER_UI_PAGE_INFO_PAGE_INFO_CONSTANTS_H_
#import <Foundation/Foundation.h>
// Accessibility identifier for the page info view.
extern NSString* const kPageInfoViewAccessibilityIdentifier;
#endif // IOS_CHROME_BROWSER_UI_PAGE_INFO_PAGE_INFO_CONSTANTS_H_
// Copyright 2018 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/page_info/page_info_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
NSString* const kPageInfoViewAccessibilityIdentifier =
@"PageInfoViewAccessibilityIdentifier";
// Copyright 2018 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 <EarlGrey/EarlGrey.h>
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "ios/chrome/browser/ui/page_info/page_info_constants.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.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_test_case.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface PageInfoTestCase : ChromeTestCase
@end
@implementation PageInfoTestCase
// Tests that rotating the device will automatically dismiss the page info view.
- (void)testShowPageInfoAndDismissOnDeviceRotation {
[ChromeEarlGrey loadURL:GURL("https://invalid")];
[ChromeEarlGreyUI openToolsMenu];
[[[EarlGrey
selectElementWithMatcher:grey_allOf(grey_accessibilityID(
kToolsMenuSiteInformation),
grey_sufficientlyVisible(), nil)]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 200)
onElementWithMatcher:grey_accessibilityID(kPopupMenuToolsMenuTableViewId)]
performAction:grey_tap()];
// Expect that the page info view has appeared.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kPageInfoViewAccessibilityIdentifier)]
assertWithMatcher:grey_sufficientlyVisible()];
[EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeRight
errorOrNil:nil];
// Expect that the page info view has disappeared.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kPageInfoViewAccessibilityIdentifier)]
assertWithMatcher:grey_not(grey_sufficientlyVisible())];
}
@end
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/commands/page_info_commands.h" #import "ios/chrome/browser/ui/commands/page_info_commands.h"
#import "ios/chrome/browser/ui/fancy_ui/bidi_container_view.h" #import "ios/chrome/browser/ui/fancy_ui/bidi_container_view.h"
#import "ios/chrome/browser/ui/page_info/page_info_constants.h"
#include "ios/chrome/browser/ui/page_info/page_info_model.h" #include "ios/chrome/browser/ui/page_info/page_info_model.h"
#import "ios/chrome/browser/ui/page_info/requirements/page_info_presentation.h" #import "ios/chrome/browser/ui/page_info/requirements/page_info_presentation.h"
#import "ios/chrome/browser/ui/page_info/requirements/page_info_reloading.h" #import "ios/chrome/browser/ui/page_info/requirements/page_info_reloading.h"
...@@ -258,6 +259,8 @@ void PageInfoModelBubbleBridge::PerformLayout() { ...@@ -258,6 +259,8 @@ void PageInfoModelBubbleBridge::PerformLayout() {
[containerView_ setOpaque:NO]; [containerView_ setOpaque:NO];
[containerView_ setAlpha:0]; [containerView_ setAlpha:0];
[containerView_ setAccessibilityViewIsModal:YES]; [containerView_ setAccessibilityViewIsModal:YES];
containerView_.accessibilityIdentifier =
kPageInfoViewAccessibilityIdentifier;
popupContainer_ = [[UIView alloc] initWithFrame:CGRectZero]; popupContainer_ = [[UIView alloc] initWithFrame:CGRectZero];
[popupContainer_ setBackgroundColor:[UIColor whiteColor]]; [popupContainer_ setBackgroundColor:[UIColor whiteColor]];
......
...@@ -96,6 +96,7 @@ chrome_ios_eg_test("ios_chrome_ui_egtests") { ...@@ -96,6 +96,7 @@ chrome_ios_eg_test("ios_chrome_ui_egtests") {
"//ios/chrome/browser/ui/history:eg_tests", "//ios/chrome/browser/ui/history:eg_tests",
"//ios/chrome/browser/ui/infobars:eg_tests", "//ios/chrome/browser/ui/infobars:eg_tests",
"//ios/chrome/browser/ui/ntp:eg_tests", "//ios/chrome/browser/ui/ntp:eg_tests",
"//ios/chrome/browser/ui/page_info:eg_tests",
"//ios/chrome/browser/ui/payments:eg_tests", "//ios/chrome/browser/ui/payments:eg_tests",
"//ios/chrome/browser/ui/popup_menu:eg_tests", "//ios/chrome/browser/ui/popup_menu:eg_tests",
"//ios/chrome/browser/ui/print:eg_tests", "//ios/chrome/browser/ui/print:eg_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