Commit a1e1b4dd authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

Revert "[iOS] Add WebAppInterface."

This reverts commit e8e69e97.

Reason for revert: causing crbug.com/1070440

Original change's description:
> [iOS] Add WebAppInterface.
> 
> This interface returns the additional standard and secure schemes added
> by web::RegisterWebSchemes() so that these schemes can be used in the
> test process for EG2 tests.
> 
> Bug: none
> Change-Id: Id02340bc11bc725ecc2c9b802455b8d669ec2b5d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2144840
> Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
> Auto-Submit: Kurt Horimoto <kkhorimoto@chromium.org>
> Reviewed-by: Eugene But <eugenebut@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#758601}

TBR=eugenebut@chromium.org,kkhorimoto@chromium.org

Change-Id: Id05ff8c9b893b48b4e73d3245938d64bbdea8c7f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: none
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2148162Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758659}
parent 3dc5a1e5
......@@ -551,7 +551,6 @@ source_set("eg_test_support+eg2") {
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
"//ios/third_party/gtx:gtx+link",
"//ios/web:eg_test_support+eg2",
"//ios/web/public/test:element_selector",
"//ios/web/public/test/http_server",
"//net:test_support",
......
......@@ -14,10 +14,8 @@
#import "ios/chrome/test/earl_grey/chrome_test_case_app_interface.h"
#import "ios/testing/earl_grey/app_launch_manager.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#import "ios/web/public/test/earl_grey/web_app_interface.h"
#import "ios/web/public/test/http_server/http_server.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "url/url_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -141,16 +139,6 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeTestCaseAppInterface)
// Starts the HTTP server. Should only be called when the server is stopped.
+ (void)startHTTPServer;
// Resets the scheme registry to use for the test case.
+ (void)setSchemeRegistry:
(std::unique_ptr<url::ScopedSchemeRegistryForTests>)registry;
// Registers the URL schemes from the ChromeWebClient.
+ (void)registerURLSchemes;
// Unregisters the URL schemes from the ChromeWebClient.
+ (void)unregisterURLSchemes;
// Returns a NSArray of test names in this class that contain the prefix
// "FLAKY_".
+ (NSArray*)flakyTestNames;
......@@ -217,7 +205,6 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeTestCaseAppInterface)
+ (void)tearDown {
[[self class] disableMockAuthentication];
[[self class] stopHTTPServer];
[[self class] unregisterURLSchemes];
[super tearDown];
gExecutedSetUpForTestCase = false;
}
......@@ -361,41 +348,6 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeTestCaseAppInterface)
server.StartOrDie(base::FilePath(base::SysNSStringToUTF8(bundlePath)));
}
+ (void)setSchemeRegistry:
(std::unique_ptr<url::ScopedSchemeRegistryForTests>)registry {
static std::unique_ptr<url::ScopedSchemeRegistryForTests>
testCaseSchemeRegistry;
testCaseSchemeRegistry = std::move(registry);
}
+ (void)registerURLSchemes {
// Create a new scoped registry for the test case class.
std::unique_ptr<url::ScopedSchemeRegistryForTests> schemeRegistry =
std::make_unique<url::ScopedSchemeRegistryForTests>();
[[self class] setSchemeRegistry:std::move(schemeRegistry)];
url::ClearSchemesForTests();
// Add the additional schemes from the WebAppInterface.
for (NSString* scheme in [WebAppInterface additionalStandardSchemes]) {
url::AddStandardScheme(base::SysNSStringToUTF8(scheme).c_str(),
url::SCHEME_WITH_HOST);
}
for (NSString* scheme in [WebAppInterface additionalSecureSchemes]) {
url::AddSecureScheme(base::SysNSStringToUTF8(scheme).c_str());
}
// Prevent future modification of the schemes lists. This is to prevent
// accidental creation of data races in the program. Add*Scheme aren't
// threadsafe so must be called when GURL isn't used on any other thread. This
// is really easy to mess up, so we say that all calls to Add*Scheme in Chrome
// must be inside this function.
url::LockSchemeRegistries();
}
+ (void)unregisterURLSchemes {
[[self class] setSchemeRegistry:nullptr];
}
+ (NSArray*)flakyTestNames {
const char kFlakyTestPrefix[] = "FLAKY";
unsigned int count = 0;
......@@ -445,7 +397,6 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeTestCaseAppInterface)
[[self class] startHTTPServer];
[[self class] enableMockAuthentication];
[[self class] registerURLSchemes];
// Sometimes on start up there can be infobars (e.g. restore session), so
// ensure the UI is in a clean state.
......
......@@ -120,8 +120,6 @@ source_set("earl_grey_test_support") {
sources = [
"public/test/earl_grey/js_test_util.h",
"public/test/earl_grey/js_test_util.mm",
"public/test/earl_grey/web_app_interface.h",
"public/test/earl_grey/web_app_interface.mm",
"public/test/earl_grey/web_view_actions.h",
"public/test/earl_grey/web_view_actions.mm",
"public/test/earl_grey/web_view_matchers.h",
......@@ -149,8 +147,6 @@ source_set("eg_app_support+eg2") {
sources = [
"public/test/earl_grey/js_test_util.h",
"public/test/earl_grey/js_test_util.mm",
"public/test/earl_grey/web_app_interface.h",
"public/test/earl_grey/web_app_interface.mm",
"public/test/earl_grey/web_view_actions.h",
"public/test/earl_grey/web_view_actions.mm",
"public/test/earl_grey/web_view_matchers.h",
......@@ -158,23 +154,6 @@ source_set("eg_app_support+eg2") {
]
}
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 = [
"public/test/earl_grey/web_app_interface.h",
"public/test/earl_grey/web_app_interface_stub.mm",
]
deps = [
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
]
}
source_set("run_all_unittests") {
testonly = true
sources = [ "test/run_all_unittests.cc" ]
......
// 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_WEB_PUBLIC_TEST_EARL_GREY_WEB_APP_INTERFACE_H_
#define IOS_WEB_PUBLIC_TEST_EARL_GREY_WEB_APP_INTERFACE_H_
#import <Foundation/Foundation.h>
// WebAppInterface contains the app-side implementation for helpers.
// These helpers are compiled into the app binary and can be called from either
// app or test code.
@interface WebAppInterface : NSObject
// Returns a list of additional standard schemes registered by
// web::RegisterWebSchemes().
+ (NSArray<NSString*>*)additionalStandardSchemes;
// Returns a list of additional secure schemes registered by
// web::RegisterWebSchemes().
+ (NSArray<NSString*>*)additionalSecureSchemes;
@end
#endif // IOS_WEB_PUBLIC_TEST_EARL_GREY_WEB_APP_INTERFACE_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/web/public/test/earl_grey/web_app_interface.h"
#include "base/logging.h"
#include "base/strings/sys_string_conversions.h"
#import "ios/web/public/web_client.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation WebAppInterface
+ (NSArray<NSString*>*)additionalStandardSchemes {
web::WebClient::Schemes webClientSchemes;
web::GetWebClient()->AddAdditionalSchemes(&webClientSchemes);
NSMutableArray<NSString*>* schemes = [NSMutableArray<NSString*> array];
const std::vector<std::string>& standardSchemes =
webClientSchemes.standard_schemes;
for (size_t i = 0; i < standardSchemes.size(); ++i) {
[schemes addObject:base::SysUTF8ToNSString(standardSchemes[i])];
}
return schemes;
}
+ (NSArray<NSString*>*)additionalSecureSchemes {
web::WebClient::Schemes webClientSchemes;
web::GetWebClient()->AddAdditionalSchemes(&webClientSchemes);
NSMutableArray<NSString*>* schemes = [NSMutableArray<NSString*> array];
const std::vector<std::string>& secureSchemes =
webClientSchemes.secure_schemes;
for (size_t i = 0; i < secureSchemes.size(); ++i) {
[schemes addObject:base::SysUTF8ToNSString(secureSchemes[i])];
}
return schemes;
}
@end
// 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/web/public/test/earl_grey/web_app_interface.h"
#import "ios/third_party/earl_grey2/src/CommonLib/DistantObject/GREYTestApplicationDistantObject.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(WebAppInterface)
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