Commit 68d4ce1d authored by Nazerke's avatar Nazerke Committed by Commit Bot

[iOS][eg2] Convert handoff manager EG tests to EG2

This CL adds all handoff manager tests to EG2 target
and updates headers and adds eg2_test source_set in
build file. Moreover, new app interface for handoff
tests is being introduced.

Bug: 987646
Change-Id: I3410f778e9f9daece1767a4f0a73c168f6e9aef0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872209Reviewed-by: default avatarRobbie Gibson <rkgibson@google.com>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Nazerke Kalidolda <nazerke@google.com>
Auto-Submit: Nazerke Kalidolda <nazerke@google.com>
Cr-Commit-Position: refs/heads/master@{#708953}
parent dcf155ff
......@@ -38,18 +38,64 @@ source_set("unit_tests") {
]
}
source_set("eg_tests") {
source_set("test_support") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"handoff_manager_egtest.mm",
"handoff_manager_app_interface.h",
"handoff_manager_app_interface.mm",
]
deps = [
":device_sharing",
"//components/handoff",
"//ios/chrome/test/app:test_support",
]
}
source_set("eg_app_support+eg2") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"handoff_manager_app_interface.h",
"handoff_manager_app_interface.mm",
]
deps = [
":device_sharing",
"//components/handoff",
"//ios/chrome/browser/ui/util",
"//ios/chrome/test/app:test_support",
]
}
source_set("eg_test_support+eg2") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"handoff_manager_app_interface.h",
]
}
source_set("eg_tests") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"handoff_manager_egtest.mm",
]
deps = [
":test_support",
"//ios/chrome/browser/ui/util",
"//ios/chrome/test/earl_grey:test_support",
"//ios/testing/earl_grey:earl_grey_support",
"//ios/third_party/earl_grey:earl_grey+link",
"//ios/web/public/test/http_server",
"//net",
......@@ -57,3 +103,29 @@ source_set("eg_tests") {
]
libs = [ "XCTest.framework" ]
}
source_set("eg2_tests") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"handoff_manager_egtest.mm",
]
deps = [
":eg_test_support+eg2",
"//ios/chrome/browser/ui/util",
"//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",
"//url",
]
libs = [ "UIKit.framework" ]
}
// 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_DEVICE_SHARING_HANDOFF_MANAGER_APP_INTERFACE_H_
#define IOS_CHROME_BROWSER_DEVICE_SHARING_HANDOFF_MANAGER_APP_INTERFACE_H_
#import <UIKit/UIKit.h>
// The app interface for handoff tests.
@interface HandoffManagerAppInterface : NSObject
// Current user activity web page url from the handoff manager.
+ (NSURL*)currentUserActivityWebPageURL;
@end
#endif // IOS_CHROME_BROWSER_DEVICE_SHARING_HANDOFF_MANAGER_APP_INTERFACE_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/device_sharing/handoff_manager_app_interface.h"
#import "components/handoff/handoff_manager.h"
#import "ios/chrome/browser/device_sharing/device_sharing_manager.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation HandoffManagerAppInterface
+ (NSURL*)currentUserActivityWebPageURL {
HandoffManager* manager =
[chrome_test_util::GetDeviceSharingManager() handoffManager];
return manager.userActivityWebpageURL;
}
@end
......@@ -2,15 +2,12 @@
// 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 <XCTest/XCTest.h>
#import "components/handoff/handoff_manager.h"
#import "ios/chrome/browser/device_sharing/device_sharing_manager.h"
#include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/browser/device_sharing/handoff_manager_app_interface.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#include "ios/web/public/test/http_server/http_server.h"
#include "ios/web/public/test/http_server/http_server_util.h"
#import "net/base/mac/url_conversions.h"
......@@ -20,20 +17,24 @@
#error "This file requires ARC support."
#endif
#if defined(CHROME_EARL_GREY_2)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat-extra-semi"
GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(HandoffManagerAppInterface);
#pragma clang diagnostic pop
#endif // defined(CHROME_EARL_GREY_2)
namespace {
// Checks that Handoff will report the specified |gurl|.
void AssertHandoffURL(const GURL& gurl) {
HandoffManager* manager =
[chrome_test_util::GetDeviceSharingManager() handoffManager];
GREYAssertTrue(manager != nil, @"Handoff Manager should not be nil");
NSURL* handoffURL =
[HandoffManagerAppInterface currentUserActivityWebPageURL];
if (gurl.is_valid()) {
NSURL* URL = net::NSURLWithGURL(gurl);
GREYAssertTrue([manager.userActivityWebpageURL isEqual:URL],
@"Incorrect Handoff URL.");
GREYAssertTrue([handoffURL isEqual:URL], @"Incorrect Handoff URL.");
} else {
GREYAssertTrue(manager.userActivityWebpageURL == nil,
@"Handoff URL is not nil.");
GREYAssertTrue(handoffURL == nil, @"Handoff URL is not nil.");
}
}
......
......@@ -361,6 +361,7 @@ source_set("eg_app_support+eg2") {
"//ios/chrome/browser/autofill",
"//ios/chrome/browser/autofill/automation:eg_app_support+eg2",
"//ios/chrome/browser/content_settings:content_settings",
"//ios/chrome/browser/device_sharing:eg_app_support+eg2",
"//ios/chrome/browser/ntp:features",
"//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/browser/ui/authentication/cells",
......
......@@ -33,6 +33,7 @@ chrome_ios_eg2_test("ios_chrome_integration_eg2tests_module") {
xcode_test_application_name = "ios_chrome_eg2tests"
deps = [
"//ios/chrome/browser/device_sharing:eg2_tests",
"//ios/chrome/browser/ntp_tiles:eg2_tests",
"//ios/chrome/browser/prerender: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