Commit 6cd6c601 authored by Ewann's avatar Ewann Committed by Commit Bot

[iOS][PageInfo] Adds EG2 Tests

This CL adds EG2 the following tests for the page info:
- Tests that rotating the device will don't dismiss the page info view.
- Tests that opening the page info on a Chromium page displays the
correct information.

Bug: 1147414
Change-Id: I83f3353934e71dba698909fff0ac419e0a182adc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2529106
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831033}
parent dbc9e705
......@@ -98,3 +98,26 @@ source_set("coordinator") {
]
frameworks = [ "UIKit.framework" ]
}
source_set("eg2_tests") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [ "page_info_egtest.mm" ]
deps = [
":constants",
"//components/strings",
"//ios/chrome/app/strings",
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
"//ui/base",
]
frameworks = [
"UIKit.framework",
"XCTest.framework",
]
}
// 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 <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#include "components/strings/grit/components_chromium_strings.h"
#import "ios/chrome/browser/ui/page_info/page_info_constants.h"
#include "ios/chrome/grit/ios_chromium_strings.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_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#include "ui/base/l10n/l10n_util.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 don't dismiss the page info view.
- (void)testShowPageInfoRotation {
[ChromeEarlGrey loadURL:GURL("https://invalid")];
[ChromeEarlGreyUI openPageInfo];
// Checks that the page info view has appeared.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kPageInfoViewAccessibilityIdentifier)]
assertWithMatcher:grey_sufficientlyVisible()];
// Rotates the device and checks that the page info view is still presented.
[EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeRight
error:nil];
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kPageInfoViewAccessibilityIdentifier)]
assertWithMatcher:grey_sufficientlyVisible()];
// Closes the page info using the 'Done' button.
[[EarlGrey
selectElementWithMatcher:chrome_test_util::NavigationBarDoneButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kPageInfoViewAccessibilityIdentifier)]
assertWithMatcher:grey_nil()];
}
// Tests that opening the page info on a Chromium page displays the correct
// information.
- (void)testShowPageInfoChromePage {
[ChromeEarlGrey loadURL:GURL("chrome://version")];
[ChromeEarlGreyUI openPageInfo];
// Checks that the page info view has appeared.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kPageInfoViewAccessibilityIdentifier)]
assertWithMatcher:grey_sufficientlyVisible()];
// Checks that “You’re viewing a secure Chrome page.” is displayed.
[[EarlGrey selectElementWithMatcher:grey_text(l10n_util::GetNSString(
IDS_PAGE_INFO_INTERNAL_PAGE))]
assertWithMatcher:grey_sufficientlyVisible()];
}
@end
......@@ -107,6 +107,9 @@
// Waits for the app to idle.
- (void)waitForAppToIdle;
// Opens pageInfo via the tools menu.
- (void)openPageInfo;
@end
#endif // IOS_CHROME_TEST_EARL_GREY_CHROME_EARL_GREY_UI_H_
......@@ -280,6 +280,17 @@ class ScopedDisableTimerTracking {
GREYWaitForAppToIdle(@"App failed to idle");
}
- (void)openPageInfo {
[self openToolsMenu];
[[[EarlGrey
selectElementWithMatcher:grey_allOf(grey_accessibilityID(
kToolsMenuSiteInformation),
grey_sufficientlyVisible(), nil)]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 200)
onElementWithMatcher:grey_accessibilityID(kPopupMenuToolsMenuTableViewId)]
performAction:grey_tap()];
}
#pragma mark - Private
// Clears all browsing data from the device. This method needs to be called when
......
......@@ -158,6 +158,7 @@ chrome_ios_eg2_test("ios_chrome_ui_eg2tests_module") {
"//ios/chrome/browser/ui/omnibox:eg2_tests",
"//ios/chrome/browser/ui/omnibox/popup:eg2_tests",
"//ios/chrome/browser/ui/open_in:eg2_tests",
"//ios/chrome/browser/ui/page_info:eg2_tests",
"//ios/chrome/browser/ui/passwords:eg2_tests",
"//ios/chrome/browser/ui/popup_menu:eg2_tests",
"//ios/chrome/browser/ui/qr_scanner: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