Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Side by Side Diff: ios/chrome/browser/ui/browser_view_controller_unittest.mm

Issue 2770223003: [ios] Switches ToolbarModelDelegateIOS to use WebStateList. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Foundation/Foundation.h> 5 #import <Foundation/Foundation.h>
6 #import <PassKit/PassKit.h> 6 #import <PassKit/PassKit.h>
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 30 matching lines...) Expand all
41 #import "ios/chrome/browser/ui/page_not_available_controller.h" 41 #import "ios/chrome/browser/ui/page_not_available_controller.h"
42 #include "ios/chrome/browser/ui/toolbar/test_toolbar_model_ios.h" 42 #include "ios/chrome/browser/ui/toolbar/test_toolbar_model_ios.h"
43 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" 43 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h"
44 #include "ios/chrome/browser/ui/ui_util.h" 44 #include "ios/chrome/browser/ui/ui_util.h"
45 #import "ios/chrome/browser/web/error_page_content.h" 45 #import "ios/chrome/browser/web/error_page_content.h"
46 #import "ios/chrome/browser/web/passkit_dialog_provider.h" 46 #import "ios/chrome/browser/web/passkit_dialog_provider.h"
47 #include "ios/chrome/grit/ios_strings.h" 47 #include "ios/chrome/grit/ios_strings.h"
48 #include "ios/chrome/test/block_cleanup_test.h" 48 #include "ios/chrome/test/block_cleanup_test.h"
49 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h" 49 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h"
50 #include "ios/chrome/test/testing_application_context.h" 50 #include "ios/chrome/test/testing_application_context.h"
51 #include "ios/shared/chrome/browser/tabs/fake_web_state_list_delegate.h"
52 #include "ios/shared/chrome/browser/tabs/web_state_list.h"
51 #import "ios/testing/ocmock_complex_type_helper.h" 53 #import "ios/testing/ocmock_complex_type_helper.h"
52 #include "ios/web/public/referrer.h" 54 #include "ios/web/public/referrer.h"
53 #include "ios/web/public/test/test_web_thread_bundle.h" 55 #include "ios/web/public/test/test_web_thread_bundle.h"
54 #import "ios/web/public/web_state/ui/crw_native_content_provider.h" 56 #import "ios/web/public/web_state/ui/crw_native_content_provider.h"
55 #import "ios/web/web_state/ui/crw_web_controller.h" 57 #import "ios/web/web_state/ui/crw_web_controller.h"
56 #import "ios/web/web_state/web_state_impl.h" 58 #import "ios/web/web_state/web_state_impl.h"
57 #import "net/base/mac/url_conversions.h" 59 #import "net/base/mac/url_conversions.h"
58 #include "net/url_request/url_request_test_util.h" 60 #include "net/url_request/url_request_test_util.h"
59 #include "testing/gmock/include/gmock/gmock.h" 61 #include "testing/gmock/include/gmock/gmock.h"
60 #include "testing/gtest/include/gtest/gtest.h" 62 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 webState_ = webState; 108 webState_ = webState;
107 } 109 }
108 - (web::NavigationManager*)navigationManager { 110 - (web::NavigationManager*)navigationManager {
109 return &(webState_->GetNavigationManagerImpl()); 111 return &(webState_->GetNavigationManagerImpl());
110 } 112 }
111 - (web::NavigationManagerImpl*)navigationManagerImpl { 113 - (web::NavigationManagerImpl*)navigationManagerImpl {
112 return &(webState_->GetNavigationManagerImpl()); 114 return &(webState_->GetNavigationManagerImpl());
113 } 115 }
114 @end 116 @end
115 117
118 @interface BVCTestTabModel : OCMockComplexTypeHelper
rohitrao (ping after 24h) 2017/03/24 14:13:48 This is "broken" because the ToolbarModel's WebSta
119 - (instancetype)init NS_DESIGNATED_INITIALIZER;
120 @end
121
122 @implementation BVCTestTabModel {
123 FakeWebStateListDelegate _webStateListDelegate;
124 std::unique_ptr<WebStateList> _webStateList;
125 }
126
127 - (instancetype)init {
128 if ((self = [super
129 initWithRepresentedObject:[OCMockObject
130 niceMockForClass:[TabModel class]]])) {
131 _webStateList = base::MakeUnique<WebStateList>(&_webStateListDelegate,
132 WebStateList::WebStateOwned);
133 }
134 return self;
135 }
136
137 - (WebStateList*)webStateList {
138 return _webStateList.get();
139 }
140 @end
141
116 #pragma mark - 142 #pragma mark -
117 143
118 namespace { 144 namespace {
119 class BrowserViewControllerTest : public BlockCleanupTest { 145 class BrowserViewControllerTest : public BlockCleanupTest {
120 public: 146 public:
121 BrowserViewControllerTest() {} 147 BrowserViewControllerTest() {}
122 148
123 protected: 149 protected:
124 void SetUp() override { 150 void SetUp() override {
125 BlockCleanupTest::SetUp(); 151 BlockCleanupTest::SetUp();
(...skipping 13 matching lines...) Expand all
139 ios::TemplateURLServiceFactory::GetInstance(), 165 ios::TemplateURLServiceFactory::GetInstance(),
140 ios::TemplateURLServiceFactory::GetDefaultFactory()); 166 ios::TemplateURLServiceFactory::GetDefaultFactory());
141 chrome_browser_state_ = test_cbs_builder.Build(); 167 chrome_browser_state_ = test_cbs_builder.Build();
142 chrome_browser_state_->CreateBookmarkModel(false); 168 chrome_browser_state_->CreateBookmarkModel(false);
143 bookmarks::BookmarkModel* bookmark_model = 169 bookmarks::BookmarkModel* bookmark_model =
144 ios::BookmarkModelFactory::GetForBrowserState( 170 ios::BookmarkModelFactory::GetForBrowserState(
145 chrome_browser_state_.get()); 171 chrome_browser_state_.get());
146 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); 172 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model);
147 173
148 // Set up mock TabModel, Tab, and CRWWebController. 174 // Set up mock TabModel, Tab, and CRWWebController.
149 id tabModel = [OCMockObject mockForClass:[TabModel class]]; 175 base::scoped_nsobject<id> tabModel([[BVCTestTabModel alloc] init]);
150 base::scoped_nsobject<id> currentTab([[BVCTestTabMock alloc] 176 base::scoped_nsobject<id> currentTab([[BVCTestTabMock alloc]
151 initWithRepresentedObject:[OCMockObject niceMockForClass:[Tab class]]]); 177 initWithRepresentedObject:[OCMockObject niceMockForClass:[Tab class]]]);
152 id webControllerMock = 178 id webControllerMock =
153 [OCMockObject niceMockForClass:[CRWWebController class]]; 179 [OCMockObject niceMockForClass:[CRWWebController class]];
154 180
155 // Stub methods for TabModel. 181 // Stub methods for TabModel.
156 NSUInteger tabCount = 1; 182 NSUInteger tabCount = 1;
157 [[[tabModel stub] andReturnValue:OCMOCK_VALUE(tabCount)] count]; 183 [[[tabModel stub] andReturnValue:OCMOCK_VALUE(tabCount)] count];
158 BOOL enabled = YES; 184 BOOL enabled = YES;
159 [[[tabModel stub] andReturnValue:OCMOCK_VALUE(enabled)] webUsageEnabled]; 185 [[[tabModel stub] andReturnValue:OCMOCK_VALUE(enabled)] webUsageEnabled];
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 static_cast<OCMockObject*>(shareController_.get()); 565 static_cast<OCMockObject*>(shareController_.get());
540 [[shareControllerMock expect] cancelShareAnimated:NO]; 566 [[shareControllerMock expect] cancelShareAnimated:NO];
541 EXPECT_CALL(*this, OnCompletionCalled()); 567 EXPECT_CALL(*this, OnCompletionCalled());
542 [bvc_ clearPresentedStateWithCompletion:^{ 568 [bvc_ clearPresentedStateWithCompletion:^{
543 this->OnCompletionCalled(); 569 this->OnCompletionCalled();
544 }]; 570 }];
545 EXPECT_OCMOCK_VERIFY(shareControllerMock); 571 EXPECT_OCMOCK_VERIFY(shareControllerMock);
546 } 572 }
547 573
548 } // namespace 574 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698