OLD | NEW |
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 Loading... |
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" | |
53 #import "ios/testing/ocmock_complex_type_helper.h" | 51 #import "ios/testing/ocmock_complex_type_helper.h" |
54 #include "ios/web/public/referrer.h" | 52 #include "ios/web/public/referrer.h" |
55 #include "ios/web/public/test/test_web_thread_bundle.h" | 53 #include "ios/web/public/test/test_web_thread_bundle.h" |
56 #import "ios/web/public/web_state/ui/crw_native_content_provider.h" | 54 #import "ios/web/public/web_state/ui/crw_native_content_provider.h" |
57 #import "ios/web/web_state/ui/crw_web_controller.h" | 55 #import "ios/web/web_state/ui/crw_web_controller.h" |
58 #import "ios/web/web_state/web_state_impl.h" | 56 #import "ios/web/web_state/web_state_impl.h" |
59 #import "net/base/mac/url_conversions.h" | 57 #import "net/base/mac/url_conversions.h" |
60 #include "net/url_request/url_request_test_util.h" | 58 #include "net/url_request/url_request_test_util.h" |
61 #include "testing/gmock/include/gmock/gmock.h" | 59 #include "testing/gmock/include/gmock/gmock.h" |
62 #include "testing/gtest/include/gtest/gtest.h" | 60 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 webState_ = webState; | 106 webState_ = webState; |
109 } | 107 } |
110 - (web::NavigationManager*)navigationManager { | 108 - (web::NavigationManager*)navigationManager { |
111 return &(webState_->GetNavigationManagerImpl()); | 109 return &(webState_->GetNavigationManagerImpl()); |
112 } | 110 } |
113 - (web::NavigationManagerImpl*)navigationManagerImpl { | 111 - (web::NavigationManagerImpl*)navigationManagerImpl { |
114 return &(webState_->GetNavigationManagerImpl()); | 112 return &(webState_->GetNavigationManagerImpl()); |
115 } | 113 } |
116 @end | 114 @end |
117 | 115 |
118 @interface BVCTestTabModel : OCMockComplexTypeHelper | |
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 | |
142 #pragma mark - | 116 #pragma mark - |
143 | 117 |
144 namespace { | 118 namespace { |
145 class BrowserViewControllerTest : public BlockCleanupTest { | 119 class BrowserViewControllerTest : public BlockCleanupTest { |
146 public: | 120 public: |
147 BrowserViewControllerTest() {} | 121 BrowserViewControllerTest() {} |
148 | 122 |
149 protected: | 123 protected: |
150 void SetUp() override { | 124 void SetUp() override { |
151 BlockCleanupTest::SetUp(); | 125 BlockCleanupTest::SetUp(); |
(...skipping 13 matching lines...) Expand all Loading... |
165 ios::TemplateURLServiceFactory::GetInstance(), | 139 ios::TemplateURLServiceFactory::GetInstance(), |
166 ios::TemplateURLServiceFactory::GetDefaultFactory()); | 140 ios::TemplateURLServiceFactory::GetDefaultFactory()); |
167 chrome_browser_state_ = test_cbs_builder.Build(); | 141 chrome_browser_state_ = test_cbs_builder.Build(); |
168 chrome_browser_state_->CreateBookmarkModel(false); | 142 chrome_browser_state_->CreateBookmarkModel(false); |
169 bookmarks::BookmarkModel* bookmark_model = | 143 bookmarks::BookmarkModel* bookmark_model = |
170 ios::BookmarkModelFactory::GetForBrowserState( | 144 ios::BookmarkModelFactory::GetForBrowserState( |
171 chrome_browser_state_.get()); | 145 chrome_browser_state_.get()); |
172 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); | 146 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); |
173 | 147 |
174 // Set up mock TabModel, Tab, and CRWWebController. | 148 // Set up mock TabModel, Tab, and CRWWebController. |
175 base::scoped_nsobject<id> tabModel([[BVCTestTabModel alloc] init]); | 149 id tabModel = [OCMockObject mockForClass:[TabModel class]]; |
176 base::scoped_nsobject<id> currentTab([[BVCTestTabMock alloc] | 150 base::scoped_nsobject<id> currentTab([[BVCTestTabMock alloc] |
177 initWithRepresentedObject:[OCMockObject niceMockForClass:[Tab class]]]); | 151 initWithRepresentedObject:[OCMockObject niceMockForClass:[Tab class]]]); |
178 id webControllerMock = | 152 id webControllerMock = |
179 [OCMockObject niceMockForClass:[CRWWebController class]]; | 153 [OCMockObject niceMockForClass:[CRWWebController class]]; |
180 | 154 |
181 // Stub methods for TabModel. | 155 // Stub methods for TabModel. |
182 NSUInteger tabCount = 1; | 156 NSUInteger tabCount = 1; |
183 [[[tabModel stub] andReturnValue:OCMOCK_VALUE(tabCount)] count]; | 157 [[[tabModel stub] andReturnValue:OCMOCK_VALUE(tabCount)] count]; |
184 BOOL enabled = YES; | 158 BOOL enabled = YES; |
185 [[[tabModel stub] andReturnValue:OCMOCK_VALUE(enabled)] webUsageEnabled]; | 159 [[[tabModel stub] andReturnValue:OCMOCK_VALUE(enabled)] webUsageEnabled]; |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 static_cast<OCMockObject*>(shareController_.get()); | 539 static_cast<OCMockObject*>(shareController_.get()); |
566 [[shareControllerMock expect] cancelShareAnimated:NO]; | 540 [[shareControllerMock expect] cancelShareAnimated:NO]; |
567 EXPECT_CALL(*this, OnCompletionCalled()); | 541 EXPECT_CALL(*this, OnCompletionCalled()); |
568 [bvc_ clearPresentedStateWithCompletion:^{ | 542 [bvc_ clearPresentedStateWithCompletion:^{ |
569 this->OnCompletionCalled(); | 543 this->OnCompletionCalled(); |
570 }]; | 544 }]; |
571 EXPECT_OCMOCK_VERIFY(shareControllerMock); | 545 EXPECT_OCMOCK_VERIFY(shareControllerMock); |
572 } | 546 } |
573 | 547 |
574 } // namespace | 548 } // namespace |
OLD | NEW |