Commit 52f3b67e authored by Nazerke's avatar Nazerke Committed by Commit Bot

[iOS][tabmodel] Remove TabModel use in UserActivityHandler.

This CL removes the use of TabModel in UserActivityHandler which was used
for getting WebStateList; and uses a browser to get WebStateList from
BrowserInterfaceProvider.

Change-Id: I2422071eccd7a5429b195e1b21be551f3bf48fce
Bug: 1049845, 1045575
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2153027Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Nazerke Kalidolda <nazerke@google.com>
Cr-Commit-Position: refs/heads/master@{#762788}
parent 3750b106
...@@ -386,8 +386,7 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher ...@@ -386,8 +386,7 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher
[UserActivityHandler [UserActivityHandler
handleStartupParametersWithTabOpener:tabOpener handleStartupParametersWithTabOpener:tabOpener
startupInformation:_startupInformation startupInformation:_startupInformation
interfaceProvider:_browserLauncher browserState:currentInterface.browserState];
.interfaceProvider];
} else if ([tabOpener shouldOpenNTPTabOnActivationOfTabModel:currentInterface } else if ([tabOpener shouldOpenNTPTabOnActivationOfTabModel:currentInterface
.tabModel]) { .tabModel]) {
// Opens an NTP if needed. // Opens an NTP if needed.
......
...@@ -66,11 +66,10 @@ namespace { ...@@ -66,11 +66,10 @@ namespace {
typedef BOOL (^DecisionBlock)(id self); typedef BOOL (^DecisionBlock)(id self);
// A block that takes the arguments of UserActivityHandler's // A block that takes the arguments of UserActivityHandler's
// +handleStartupParametersWithTabOpener. // +handleStartupParametersWithTabOpener.
typedef void (^HandleStartupParam)( typedef void (^HandleStartupParam)(id self,
id self, id<TabOpening> tabOpener,
id<TabOpening> tabOpener, id<StartupInformation> startupInformation,
id<StartupInformation> startupInformation, ChromeBrowserState* browserState);
id<BrowserInterfaceProvider> interfaceProvider);
class FakeAppDistributionProvider : public AppDistributionProvider { class FakeAppDistributionProvider : public AppDistributionProvider {
public: public:
...@@ -226,20 +225,19 @@ class AppStateTest : public BlockCleanupTest { ...@@ -226,20 +225,19 @@ class AppStateTest : public BlockCleanupTest {
void swizzleHandleStartupParameters( void swizzleHandleStartupParameters(
id<TabOpening> expectedTabOpener, id<TabOpening> expectedTabOpener,
id<BrowserInterfaceProvider> expectedInterfaceProvider) { ChromeBrowserState* expectedBrowserState) {
handle_startup_swizzle_block_ = handle_startup_swizzle_block_ = ^(id self, id<TabOpening> tabOpener,
^(id self, id<TabOpening> tabOpener, id<StartupInformation> startupInformation,
id<StartupInformation> startupInformation, ChromeBrowserState* browserState) {
id<BrowserInterfaceProvider> interfaceProvider) { ASSERT_EQ(startup_information_mock_, startupInformation);
ASSERT_EQ(startup_information_mock_, startupInformation); ASSERT_EQ(expectedTabOpener, tabOpener);
ASSERT_EQ(expectedTabOpener, tabOpener); ASSERT_EQ(expectedBrowserState, browserState);
ASSERT_EQ(expectedInterfaceProvider, interfaceProvider); };
};
handle_startup_swizzler_.reset(new ScopedBlockSwizzler( handle_startup_swizzler_.reset(new ScopedBlockSwizzler(
[UserActivityHandler class], [UserActivityHandler class],
@selector(handleStartupParametersWithTabOpener: @selector(handleStartupParametersWithTabOpener:
startupInformation:interfaceProvider:), startupInformation:browserState:),
handle_startup_swizzle_block_)); handle_startup_swizzle_block_));
} }
...@@ -584,7 +582,7 @@ TEST_F(AppStateTest, resumeSessionWithStartupParameters) { ...@@ -584,7 +582,7 @@ TEST_F(AppStateTest, resumeSessionWithStartupParameters) {
interfaceProvider.mainInterface.browserState = getBrowserState(); interfaceProvider.mainInterface.browserState = getBrowserState();
// Swizzle Startup Parameters. // Swizzle Startup Parameters.
swizzleHandleStartupParameters(tabOpener, interfaceProvider); swizzleHandleStartupParameters(tabOpener, getBrowserState());
UIWindow* window = [[UIWindow alloc] init]; UIWindow* window = [[UIWindow alloc] init];
AppState* appState = getAppStateWithOpenNTPAndIncognitoBlock(NO, window); AppState* appState = getAppStateWithOpenNTPAndIncognitoBlock(NO, window);
......
...@@ -66,7 +66,7 @@ const char* const kUMAMobileSessionStartFromAppsHistogram = ...@@ -66,7 +66,7 @@ const char* const kUMAMobileSessionStartFromAppsHistogram =
// TODO(crbug.com/935019): Exacly the same copy of this code is present in // TODO(crbug.com/935019): Exacly the same copy of this code is present in
// +[UserAcrtivityHandler // +[UserAcrtivityHandler
// handleStartupParametersWithTabOpener:startupInformation:interfaceProvider:] // handleStartupParametersWithTabOpener:startupInformation:browserState:]
GURL URL; GURL URL;
GURL virtualURL; GURL virtualURL;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@protocol BrowserInterfaceProvider; @protocol BrowserInterfaceProvider;
class ChromeBrowserState;
@protocol StartupInformation; @protocol StartupInformation;
@protocol TabOpening; @protocol TabOpening;
...@@ -42,8 +43,7 @@ ...@@ -42,8 +43,7 @@
+ (void)handleStartupParametersWithTabOpener:(id<TabOpening>)tabOpener + (void)handleStartupParametersWithTabOpener:(id<TabOpening>)tabOpener
startupInformation: startupInformation:
(id<StartupInformation>)startupInformation (id<StartupInformation>)startupInformation
interfaceProvider: browserState:(ChromeBrowserState*)browserState;
(id<BrowserInterfaceProvider>)interfaceProvider;
@end @end
......
...@@ -23,10 +23,13 @@ ...@@ -23,10 +23,13 @@
#import "ios/chrome/app/spotlight/actions_spotlight_manager.h" #import "ios/chrome/app/spotlight/actions_spotlight_manager.h"
#import "ios/chrome/app/spotlight/spotlight_util.h" #import "ios/chrome/app/spotlight/spotlight_util.h"
#include "ios/chrome/app/startup/chrome_app_startup_parameters.h" #include "ios/chrome/app/startup/chrome_app_startup_parameters.h"
#import "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#import "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/main/browser_list.h"
#import "ios/chrome/browser/main/browser_list_factory.h"
#include "ios/chrome/browser/metrics/first_user_action_recorder.h" #include "ios/chrome/browser/metrics/first_user_action_recorder.h"
#include "ios/chrome/browser/search_engines/template_url_service_factory.h" #include "ios/chrome/browser/search_engines/template_url_service_factory.h"
#import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/chrome/browser/u2f/u2f_tab_helper.h" #import "ios/chrome/browser/u2f/u2f_tab_helper.h"
#import "ios/chrome/browser/ui/main/browser_interface_provider.h" #import "ios/chrome/browser/ui/main/browser_interface_provider.h"
#import "ios/chrome/browser/url_loading/image_search_param_generator.h" #import "ios/chrome/browser/url_loading/image_search_param_generator.h"
...@@ -58,7 +61,7 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner"; ...@@ -58,7 +61,7 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner";
startupInformation:(id<StartupInformation>)startupInformation; startupInformation:(id<StartupInformation>)startupInformation;
// Routes Universal 2nd Factor (U2F) callback to the correct Tab. // Routes Universal 2nd Factor (U2F) callback to the correct Tab.
+ (void)routeU2FURL:(const GURL&)URL + (void)routeU2FURL:(const GURL&)URL
interfaceProvider:(id<BrowserInterfaceProvider>)interfaceProvider; browserState:(ChromeBrowserState*)browserState;
@end @end
@implementation UserActivityHandler @implementation UserActivityHandler
...@@ -233,7 +236,8 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner"; ...@@ -233,7 +236,8 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner";
[UserActivityHandler [UserActivityHandler
handleStartupParametersWithTabOpener:tabOpener handleStartupParametersWithTabOpener:tabOpener
startupInformation:startupInformation startupInformation:startupInformation
interfaceProvider:interfaceProvider]; browserState:interfaceProvider.currentInterface
.browserState];
} }
completionHandler(handledShortcutItem); completionHandler(handledShortcutItem);
} }
...@@ -248,8 +252,7 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner"; ...@@ -248,8 +252,7 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner";
+ (void)handleStartupParametersWithTabOpener:(id<TabOpening>)tabOpener + (void)handleStartupParametersWithTabOpener:(id<TabOpening>)tabOpener
startupInformation: startupInformation:
(id<StartupInformation>)startupInformation (id<StartupInformation>)startupInformation
interfaceProvider: browserState:(ChromeBrowserState*)browserState {
(id<BrowserInterfaceProvider>)interfaceProvider {
DCHECK([startupInformation startupParameters]); DCHECK([startupInformation startupParameters]);
// Do not load the external URL if the user has not accepted the terms of // Do not load the external URL if the user has not accepted the terms of
// service. This corresponds to the case when the user installed Chrome, // service. This corresponds to the case when the user installed Chrome,
...@@ -261,8 +264,7 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner"; ...@@ -261,8 +264,7 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner";
// Check if it's an U2F call. If so, route it to correct tab. // Check if it's an U2F call. If so, route it to correct tab.
// If not, open or reuse tab in main BVC. // If not, open or reuse tab in main BVC.
if (U2FTabHelper::IsU2FUrl(externalURL)) { if (U2FTabHelper::IsU2FUrl(externalURL)) {
[UserActivityHandler routeU2FURL:externalURL [UserActivityHandler routeU2FURL:externalURL browserState:browserState];
interfaceProvider:interfaceProvider];
// It's OK to clear startup parameters here because routeU2FURL works // It's OK to clear startup parameters here because routeU2FURL works
// synchronously. // synchronously.
[startupInformation setStartupParameters:nil]; [startupInformation setStartupParameters:nil];
...@@ -295,8 +297,7 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner"; ...@@ -295,8 +297,7 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner";
if (startupInformation.startupParameters.imageSearchData) { if (startupInformation.startupParameters.imageSearchData) {
TemplateURLService* templateURLService = TemplateURLService* templateURLService =
ios::TemplateURLServiceFactory::GetForBrowserState( ios::TemplateURLServiceFactory::GetForBrowserState(browserState);
interfaceProvider.mainInterface.browserState);
NSData* imageData = startupInformation.startupParameters.imageSearchData; NSData* imageData = startupInformation.startupParameters.imageSearchData;
web::NavigationManager::WebLoadParams webLoadParams = web::NavigationManager::WebLoadParams webLoadParams =
...@@ -308,8 +309,7 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner"; ...@@ -308,8 +309,7 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner";
NSString* query = startupInformation.startupParameters.textQuery; NSString* query = startupInformation.startupParameters.textQuery;
TemplateURLService* templateURLService = TemplateURLService* templateURLService =
ios::TemplateURLServiceFactory::GetForBrowserState( ios::TemplateURLServiceFactory::GetForBrowserState(browserState);
interfaceProvider.mainInterface.browserState);
const TemplateURL* defaultURL = const TemplateURL* defaultURL =
templateURLService->GetDefaultSearchProvider(); templateURLService->GetDefaultSearchProvider();
...@@ -388,25 +388,31 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner"; ...@@ -388,25 +388,31 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner";
} }
+ (void)routeU2FURL:(const GURL&)URL + (void)routeU2FURL:(const GURL&)URL
interfaceProvider:(id<BrowserInterfaceProvider>)interfaceProvider { browserState:(ChromeBrowserState*)browserState {
DCHECK(browserState);
// Retrieve the designated TabID from U2F URL. // Retrieve the designated TabID from U2F URL.
NSString* tabID = U2FTabHelper::GetTabIdFromU2FUrl(URL); NSString* tabID = U2FTabHelper::GetTabIdFromU2FUrl(URL);
if (!tabID) { if (!tabID) {
return; return;
} }
// Iterate through mainTabModel and OTRTabModel to find the corresponding tab. // Iterate through regular Browser and OTR Browser to find the corresponding
NSArray* tabModels = @[ // tab.
interfaceProvider.mainInterface.tabModel, BrowserList* browserList =
interfaceProvider.incognitoInterface.tabModel BrowserListFactory::GetForBrowserState(browserState);
]; std::set<Browser*> regularBrowsers = browserList->AllRegularBrowsers();
for (TabModel* tabModel in tabModels) { std::set<Browser*> otrBrowsers = browserList->AllIncognitoBrowsers();
WebStateList* webStateList = tabModel.webStateList; std::set<Browser*> browsers(regularBrowsers);
browsers.insert(otrBrowsers.begin(), otrBrowsers.end());
for (Browser* browser : browsers) {
WebStateList* webStateList = browser->GetWebStateList();
for (int index = 0; index < webStateList->count(); ++index) { for (int index = 0; index < webStateList->count(); ++index) {
web::WebState* webState = webStateList->GetWebStateAt(index); web::WebState* webState = webStateList->GetWebStateAt(index);
NSString* currentTabID = TabIdTabHelper::FromWebState(webState)->tab_id(); NSString* currentTabID = TabIdTabHelper::FromWebState(webState)->tab_id();
if ([currentTabID isEqualToString:tabID]) { if ([currentTabID isEqualToString:tabID]) {
U2FTabHelper::FromWebState(webState)->EvaluateU2FResult(URL); U2FTabHelper::FromWebState(webState)->EvaluateU2FResult(URL);
return;
} }
} }
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/test/scoped_command_line.h" #include "base/test/scoped_command_line.h"
#import "base/test/task_environment.h"
#include "components/handoff/handoff_utility.h" #include "components/handoff/handoff_utility.h"
#import "ios/chrome/app/app_startup_parameters.h" #import "ios/chrome/app/app_startup_parameters.h"
#include "ios/chrome/app/application_delegate/fake_startup_information.h" #include "ios/chrome/app/application_delegate/fake_startup_information.h"
...@@ -23,9 +24,12 @@ ...@@ -23,9 +24,12 @@
#include "ios/chrome/app/main_controller.h" #include "ios/chrome/app/main_controller.h"
#include "ios/chrome/app/spotlight/actions_spotlight_manager.h" #include "ios/chrome/app/spotlight/actions_spotlight_manager.h"
#import "ios/chrome/app/spotlight/spotlight_util.h" #import "ios/chrome/app/spotlight/spotlight_util.h"
#import "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
#include "ios/chrome/browser/chrome_switches.h" #include "ios/chrome/browser/chrome_switches.h"
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#import "ios/chrome/browser/tabs/tab_model.h" #import "ios/chrome/browser/main/browser_list.h"
#import "ios/chrome/browser/main/browser_list_factory.h"
#import "ios/chrome/browser/main/test_browser.h"
#import "ios/chrome/browser/u2f/u2f_tab_helper.h" #import "ios/chrome/browser/u2f/u2f_tab_helper.h"
#import "ios/chrome/browser/ui/main/test/stub_browser_interface_provider.h" #import "ios/chrome/browser/ui/main/test/stub_browser_interface_provider.h"
#import "ios/chrome/browser/url_loading/url_loading_params.h" #import "ios/chrome/browser/url_loading/url_loading_params.h"
...@@ -70,43 +74,6 @@ class FakeU2FTabHelper : public U2FTabHelper { ...@@ -70,43 +74,6 @@ class FakeU2FTabHelper : public U2FTabHelper {
DISALLOW_COPY_AND_ASSIGN(FakeU2FTabHelper); DISALLOW_COPY_AND_ASSIGN(FakeU2FTabHelper);
}; };
#pragma mark - TabModel Mock
// TabModel mock for using in UserActivity tests.
@interface UserActivityHandlerTabModelMock : NSObject
@end
@implementation UserActivityHandlerTabModelMock {
FakeWebStateListDelegate _webStateListDelegate;
std::unique_ptr<WebStateList> _webStateList;
}
- (instancetype)init {
if ((self = [super init])) {
_webStateList = std::make_unique<WebStateList>(&_webStateListDelegate);
}
return self;
}
- (web::WebState*)addWebState {
auto testWebState = std::make_unique<web::TestWebState>();
TabIdTabHelper::CreateForWebState(testWebState.get());
FakeU2FTabHelper::CreateForWebState(testWebState.get());
web::WebState* returnWebState = testWebState.get();
_webStateList->InsertWebState(0, std::move(testWebState),
WebStateList::INSERT_NO_FLAGS,
WebStateOpener());
return returnWebState;
}
- (WebStateList*)webStateList {
return _webStateList.get();
}
@end
#pragma mark - Test class. #pragma mark - Test class.
// A block that takes as arguments the caller and the arguments from // A block that takes as arguments the caller and the arguments from
...@@ -129,7 +96,7 @@ class UserActivityHandlerTest : public PlatformTest { ...@@ -129,7 +96,7 @@ class UserActivityHandlerTest : public PlatformTest {
user_activity_handler_swizzler_.reset(new ScopedBlockSwizzler( user_activity_handler_swizzler_.reset(new ScopedBlockSwizzler(
[UserActivityHandler class], [UserActivityHandler class],
@selector(handleStartupParametersWithTabOpener: @selector(handleStartupParametersWithTabOpener:
startupInformation:interfaceProvider:), startupInformation:browserState:),
swizzle_block_)); swizzle_block_));
} }
...@@ -560,14 +527,17 @@ TEST_F(UserActivityHandlerTest, HandleStartupParamsWithExternalFile) { ...@@ -560,14 +527,17 @@ TEST_F(UserActivityHandlerTest, HandleStartupParamsWithExternalFile) {
MockTabOpener* tabOpener = [[MockTabOpener alloc] init]; MockTabOpener* tabOpener = [[MockTabOpener alloc] init];
// The test will fail is a method of this object is called. // The test will fail is a method of this object is called.
id interfaceProviderMock = // id interfaceProviderMock =
[OCMockObject mockForProtocol:@protocol(BrowserInterfaceProvider)]; // [OCMockObject mockForProtocol:@protocol(BrowserInterfaceProvider)];
StubBrowserInterfaceProvider* interfaceProvider =
[[StubBrowserInterfaceProvider alloc] init];
// Action. // Action.
[UserActivityHandler [UserActivityHandler
handleStartupParametersWithTabOpener:tabOpener handleStartupParametersWithTabOpener:tabOpener
startupInformation:startupInformationMock startupInformation:startupInformationMock
interfaceProvider:interfaceProviderMock]; browserState:interfaceProvider.currentInterface
.browserState];
[tabOpener completionBlock](); [tabOpener completionBlock]();
// Tests. // Tests.
...@@ -599,14 +569,17 @@ TEST_F(UserActivityHandlerTest, HandleStartupParamsNonU2F) { ...@@ -599,14 +569,17 @@ TEST_F(UserActivityHandlerTest, HandleStartupParamsNonU2F) {
MockTabOpener* tabOpener = [[MockTabOpener alloc] init]; MockTabOpener* tabOpener = [[MockTabOpener alloc] init];
// The test will fail is a method of this object is called. // The test will fail is a method of this object is called.
id interfaceProviderMock = // id interfaceProviderMock =
[OCMockObject mockForProtocol:@protocol(BrowserInterfaceProvider)]; // [OCMockObject mockForProtocol:@protocol(BrowserInterfaceProvider)];
StubBrowserInterfaceProvider* interfaceProvider =
[[StubBrowserInterfaceProvider alloc] init];
// Action. // Action.
[UserActivityHandler [UserActivityHandler
handleStartupParametersWithTabOpener:tabOpener handleStartupParametersWithTabOpener:tabOpener
startupInformation:startupInformationMock startupInformation:startupInformationMock
interfaceProvider:interfaceProviderMock]; browserState:interfaceProvider.currentInterface
.browserState];
[tabOpener completionBlock](); [tabOpener completionBlock]();
// Tests. // Tests.
...@@ -620,10 +593,32 @@ TEST_F(UserActivityHandlerTest, HandleStartupParamsNonU2F) { ...@@ -620,10 +593,32 @@ TEST_F(UserActivityHandlerTest, HandleStartupParamsNonU2F) {
// Tests that handleStartupParameters with a U2F url opens in the correct tab. // Tests that handleStartupParameters with a U2F url opens in the correct tab.
TEST_F(UserActivityHandlerTest, HandleStartupParamsU2F) { TEST_F(UserActivityHandlerTest, HandleStartupParamsU2F) {
// Setup. // Setup.
UserActivityHandlerTabModelMock* mockTabModel = base::test::TaskEnvironment task_enviroment_;
[[UserActivityHandlerTabModelMock alloc] init];
web::WebState* web_state = [mockTabModel addWebState]; TestChromeBrowserState::Builder test_cbs_builder;
id tabModel = static_cast<id>(mockTabModel); std::unique_ptr<ChromeBrowserState> browser_state_ = test_cbs_builder.Build();
FakeWebStateListDelegate _webStateListDelegate;
std::unique_ptr<WebStateList> web_state_list_ =
std::make_unique<WebStateList>(&_webStateListDelegate);
auto testWebState = std::make_unique<web::TestWebState>();
TabIdTabHelper::CreateForWebState(testWebState.get());
FakeU2FTabHelper::CreateForWebState(testWebState.get());
web::WebState* web_state = testWebState.get();
web_state_list_->InsertWebState(0, std::move(testWebState),
WebStateList::INSERT_NO_FLAGS,
WebStateOpener());
std::unique_ptr<Browser> browser_ = std::make_unique<TestBrowser>(
browser_state_.get(), web_state_list_.get());
std::unique_ptr<Browser> otr_browser_ = std::make_unique<TestBrowser>(
browser_state_->GetOffTheRecordChromeBrowserState(),
web_state_list_.get());
BrowserList* browser_list_ =
BrowserListFactory::GetForBrowserState(browser_state_.get());
browser_list_->AddBrowser(browser_.get());
std::string urlRepresentation = base::StringPrintf( std::string urlRepresentation = base::StringPrintf(
"chromium://u2f-callback?isU2F=1&tabID=%s", "chromium://u2f-callback?isU2F=1&tabID=%s",
...@@ -642,8 +637,9 @@ TEST_F(UserActivityHandlerTest, HandleStartupParamsU2F) { ...@@ -642,8 +637,9 @@ TEST_F(UserActivityHandlerTest, HandleStartupParamsU2F) {
StubBrowserInterfaceProvider* interfaceProvider = StubBrowserInterfaceProvider* interfaceProvider =
[[StubBrowserInterfaceProvider alloc] init]; [[StubBrowserInterfaceProvider alloc] init];
interfaceProvider.mainInterface.tabModel = tabModel; interfaceProvider.mainInterface.browserState = browser_state_.get();
interfaceProvider.incognitoInterface.tabModel = tabModel; interfaceProvider.incognitoInterface.browserState =
browser_state_->GetOffTheRecordChromeBrowserState();
MockTabOpener* tabOpener = [[MockTabOpener alloc] init]; MockTabOpener* tabOpener = [[MockTabOpener alloc] init];
...@@ -651,7 +647,8 @@ TEST_F(UserActivityHandlerTest, HandleStartupParamsU2F) { ...@@ -651,7 +647,8 @@ TEST_F(UserActivityHandlerTest, HandleStartupParamsU2F) {
[UserActivityHandler [UserActivityHandler
handleStartupParametersWithTabOpener:tabOpener handleStartupParametersWithTabOpener:tabOpener
startupInformation:startupInformationMock startupInformation:startupInformationMock
interfaceProvider:interfaceProvider]; browserState:interfaceProvider.currentInterface
.browserState];
// Tests. // Tests.
EXPECT_OCMOCK_VERIFY(startupInformationMock); EXPECT_OCMOCK_VERIFY(startupInformationMock);
...@@ -687,15 +684,15 @@ TEST_F(UserActivityHandlerTest, PerformActionForShortcutItemWithRealShortcut) { ...@@ -687,15 +684,15 @@ TEST_F(UserActivityHandlerTest, PerformActionForShortcutItemWithRealShortcut) {
// The test will fail is a method of those objects is called. // The test will fail is a method of those objects is called.
id tabOpenerMock = [OCMockObject mockForProtocol:@protocol(TabOpening)]; id tabOpenerMock = [OCMockObject mockForProtocol:@protocol(TabOpening)];
id interfaceProviderMock = StubBrowserInterfaceProvider* interfaceProvider =
[OCMockObject mockForProtocol:@protocol(BrowserInterfaceProvider)]; [[StubBrowserInterfaceProvider alloc] init];
// Action. // Action.
[UserActivityHandler performActionForShortcutItem:shortcut [UserActivityHandler performActionForShortcutItem:shortcut
completionHandler:getCompletionHandler() completionHandler:getCompletionHandler()
tabOpener:tabOpenerMock tabOpener:tabOpenerMock
startupInformation:fakeStartupInformation startupInformation:fakeStartupInformation
interfaceProvider:interfaceProviderMock]; interfaceProvider:interfaceProvider];
// Tests. // Tests.
EXPECT_EQ(gurlNewTab, EXPECT_EQ(gurlNewTab,
......
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