Commit 135b143a authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Convert InfobarEGTest to EG2

Creates InfobarManagerAppInterface to allow for retrieval of InfobarManager
state.

Bug: 987646
Change-Id: Ic518fe7ffaaeec27b08f6a3e4a37a12dc84387fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1914535
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715898}
parent 45cc3fe3
...@@ -137,7 +137,68 @@ source_set("unit_tests") { ...@@ -137,7 +137,68 @@ source_set("unit_tests") {
] ]
} }
source_set("eg2_tests") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"infobar_egtest.mm",
]
deps = [
":eg_test_support+eg2",
"//base",
"//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",
"//url",
]
libs = [ "UIKit.framework" ]
}
source_set("eg_tests") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"infobar_egtest.mm",
]
deps = [
":eg_test_support",
"//base",
"//ios/chrome/test/earl_grey:test_support",
"//ios/testing/earl_grey:earl_grey_support",
"//ios/web/public/test/http_server",
"//url",
]
libs = [ "XCTest.framework" ]
}
source_set("eg_test_support") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"infobar_manager_app_interface.h",
"infobar_manager_app_interface.mm",
]
deps = [
":test_support",
"//base",
"//components/infobars/core",
"//ios/chrome/app:app_internal",
"//ios/chrome/browser/infobars",
"//ios/chrome/browser/tabs",
"//ios/chrome/browser/web_state_list",
"//ios/chrome/test/app:test_support",
]
}
source_set("test_support") { source_set("test_support") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
testonly = true testonly = true
sources = [ sources = [
...@@ -150,14 +211,20 @@ source_set("test_support") { ...@@ -150,14 +211,20 @@ source_set("test_support") {
] ]
} }
source_set("eg_tests") { source_set("eg_app_support+eg2") {
configs += [ "//build/config/compiler:enable_arc" ] defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true testonly = true
sources = [ sources = [
"infobar_egtest.mm", "infobar_manager_app_interface.h",
"infobar_manager_app_interface.mm",
"test_infobar_delegate.h",
"test_infobar_delegate.mm",
] ]
deps = [ deps = [
":test_support",
"//base", "//base",
"//components/infobars/core", "//components/infobars/core",
"//ios/chrome/app:app_internal", "//ios/chrome/app:app_internal",
...@@ -165,10 +232,17 @@ source_set("eg_tests") { ...@@ -165,10 +232,17 @@ source_set("eg_tests") {
"//ios/chrome/browser/tabs", "//ios/chrome/browser/tabs",
"//ios/chrome/browser/web_state_list", "//ios/chrome/browser/web_state_list",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/third_party/earl_grey:earl_grey+link",
"//ios/web/public/test/http_server",
"//url",
] ]
libs = [ "XCTest.framework" ] }
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 = [
"infobar_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.
#ifndef IOS_CHROME_BROWSER_UI_INFOBARS_INFOBAR_MANAGER_APP_INTERFACE_H_
#define IOS_CHROME_BROWSER_UI_INFOBARS_INFOBAR_MANAGER_APP_INTERFACE_H_
#import <UIKit/UIKit.h>
// InfobarManagerAppInterface 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 InfobarManagerAppInterface : NSObject
// Verifies that there are |totalInfobars| in the InfobarManager of the current
// active WebState.
+ (BOOL)verifyInfobarCount:(NSInteger)totalInfobars;
// Adds a TestInfoBar with |message| to the current active WebState.
+ (BOOL)addTestInfoBarToCurrentTabWithMessage:(NSString*)message;
@end
#endif // IOS_CHROME_BROWSER_UI_INFOBARS_INFOBAR_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/ui/infobars/infobar_manager_app_interface.h"
#include "components/infobars/core/infobar_manager.h"
#import "ios/chrome/app/main_controller.h"
#include "ios/chrome/browser/infobars/infobar_manager_impl.h"
#import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/chrome/browser/ui/infobars/test_infobar_delegate.h"
#import "ios/chrome/browser/web_state_list/web_state_list.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 InfobarManagerAppInterface
+ (BOOL)verifyInfobarCount:(NSInteger)totalInfobars {
MainController* mainController = chrome_test_util::GetMainController();
id<BrowserInterface> interface =
mainController.interfaceProvider.mainInterface;
web::WebState* webState =
interface.tabModel.webStateList->GetActiveWebState();
infobars::InfoBarManager* manager =
InfoBarManagerImpl::FromWebState(webState);
return totalInfobars == (NSInteger)manager->infobar_count();
}
+ (BOOL)addTestInfoBarToCurrentTabWithMessage:(NSString*)message {
MainController* mainController = chrome_test_util::GetMainController();
id<BrowserInterface> interface =
mainController.interfaceProvider.mainInterface;
web::WebState* webState =
interface.tabModel.webStateList->GetActiveWebState();
infobars::InfoBarManager* manager =
InfoBarManagerImpl::FromWebState(webState);
TestInfoBarDelegate* testInfobarDelegate = new TestInfoBarDelegate(message);
return testInfobarDelegate->Create(manager);
}
@end
...@@ -177,7 +177,7 @@ source_set("eg_app_support+eg2") { ...@@ -177,7 +177,7 @@ source_set("eg_app_support+eg2") {
] ]
deps = [ deps = [
"//ios/chrome/browser/infobars", "//ios/chrome/browser/infobars",
"//ios/chrome/browser/ui/infobars:test_support", "//ios/chrome/browser/ui/infobars:eg_app_support+eg2",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/testing:nserror_support", "//ios/testing:nserror_support",
] ]
......
...@@ -382,6 +382,8 @@ source_set("eg_app_support+eg2") { ...@@ -382,6 +382,8 @@ source_set("eg_app_support+eg2") {
"//ios/chrome/browser/ui/first_run:eg_app_support+eg2", "//ios/chrome/browser/ui/first_run:eg_app_support+eg2",
"//ios/chrome/browser/ui/fullscreen/test:eg_app_support+eg2", "//ios/chrome/browser/ui/fullscreen/test:eg_app_support+eg2",
"//ios/chrome/browser/ui/history:constants", "//ios/chrome/browser/ui/history:constants",
"//ios/chrome/browser/ui/infobars",
"//ios/chrome/browser/ui/infobars:eg_app_support+eg2",
"//ios/chrome/browser/ui/location_bar:location_bar", "//ios/chrome/browser/ui/location_bar:location_bar",
"//ios/chrome/browser/ui/omnibox:omnibox_internal", "//ios/chrome/browser/ui/omnibox:omnibox_internal",
"//ios/chrome/browser/ui/payments:payments_ui", "//ios/chrome/browser/ui/payments:payments_ui",
......
...@@ -75,6 +75,7 @@ chrome_ios_eg2_test("ios_chrome_ui_eg2tests_module") { ...@@ -75,6 +75,7 @@ chrome_ios_eg2_test("ios_chrome_ui_eg2tests_module") {
"//ios/chrome/browser/ui/download:eg2_tests", "//ios/chrome/browser/ui/download:eg2_tests",
"//ios/chrome/browser/ui/first_run:eg2_tests", "//ios/chrome/browser/ui/first_run:eg2_tests",
"//ios/chrome/browser/ui/fullscreen:eg2_tests", "//ios/chrome/browser/ui/fullscreen:eg2_tests",
"//ios/chrome/browser/ui/infobars:eg2_tests",
"//ios/chrome/browser/ui/keyboard:eg2_tests", "//ios/chrome/browser/ui/keyboard:eg2_tests",
"//ios/chrome/browser/ui/ntp:eg2_tests", "//ios/chrome/browser/ui/ntp:eg2_tests",
"//ios/chrome/browser/ui/omnibox/popup:eg2_tests", "//ios/chrome/browser/ui/omnibox/popup: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