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

Side by Side Diff: ios/chrome/browser/tabs/tab_unittest.mm

Issue 2615003002: Use ChromeBrowserStateManager instead of BrowserListIOS. (Closed)
Patch Set: Fix ios_chrome_perftests. Created 3 years, 11 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 <UIKit/UIKit.h> 5 #import <UIKit/UIKit.h>
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_path.h"
10 #include "base/ios/block_types.h" 11 #include "base/ios/block_types.h"
11 #include "base/mac/scoped_nsobject.h" 12 #include "base/mac/scoped_nsobject.h"
12 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/run_loop.h" 15 #include "base/run_loop.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "base/strings/sys_string_conversions.h" 17 #include "base/strings/sys_string_conversions.h"
17 #include "components/bookmarks/test/bookmark_test_helpers.h" 18 #include "components/bookmarks/test/bookmark_test_helpers.h"
18 #include "components/history/core/browser/history_service.h" 19 #include "components/history/core/browser/history_service.h"
19 #include "components/keyed_service/core/service_access_type.h" 20 #include "components/keyed_service/core/service_access_type.h"
20 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" 21 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
21 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" 22 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
23 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h"
22 #import "ios/chrome/browser/chrome_url_util.h" 24 #import "ios/chrome/browser/chrome_url_util.h"
23 #include "ios/chrome/browser/history/history_service_factory.h" 25 #include "ios/chrome/browser/history/history_service_factory.h"
24 #import "ios/chrome/browser/tabs/tab.h" 26 #import "ios/chrome/browser/tabs/tab.h"
25 #import "ios/chrome/browser/tabs/tab_model.h" 27 #import "ios/chrome/browser/tabs/tab_model.h"
26 #import "ios/chrome/browser/tabs/tab_private.h" 28 #import "ios/chrome/browser/tabs/tab_private.h"
27 #import "ios/chrome/browser/ui/open_in_controller.h" 29 #import "ios/chrome/browser/ui/open_in_controller.h"
28 #import "ios/chrome/browser/ui/open_in_controller_testing.h" 30 #import "ios/chrome/browser/ui/open_in_controller_testing.h"
29 #import "ios/chrome/browser/web/external_app_launcher.h" 31 #import "ios/chrome/browser/web/external_app_launcher.h"
30 #include "ios/chrome/test/block_cleanup_test.h" 32 #include "ios/chrome/test/block_cleanup_test.h"
31 #include "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_provider.h" 33 #include "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_provider.h"
34 #include "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager .h"
32 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h" 35 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h"
33 #import "ios/public/provider/chrome/browser/native_app_launcher/fake_native_app_ metadata.h" 36 #import "ios/public/provider/chrome/browser/native_app_launcher/fake_native_app_ metadata.h"
34 #import "ios/public/provider/chrome/browser/native_app_launcher/fake_native_app_ whitelist_manager.h" 37 #import "ios/public/provider/chrome/browser/native_app_launcher/fake_native_app_ whitelist_manager.h"
35 #include "ios/public/provider/chrome/browser/test_chrome_browser_provider.h" 38 #include "ios/public/provider/chrome/browser/test_chrome_browser_provider.h"
36 #import "ios/testing/ocmock_complex_type_helper.h" 39 #import "ios/testing/ocmock_complex_type_helper.h"
37 #import "ios/web/navigation/crw_session_controller.h" 40 #import "ios/web/navigation/crw_session_controller.h"
38 #import "ios/web/navigation/navigation_manager_impl.h" 41 #import "ios/web/navigation/navigation_manager_impl.h"
39 #include "ios/web/public/navigation_item.h" 42 #include "ios/web/public/navigation_item.h"
40 #import "ios/web/public/navigation_manager.h" 43 #import "ios/web/public/navigation_manager.h"
41 #include "ios/web/public/referrer.h" 44 #include "ios/web/public/referrer.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 id<NativeAppWhitelistManager> GetNativeAppWhitelistManager() const override { 156 id<NativeAppWhitelistManager> GetNativeAppWhitelistManager() const override {
154 return manager_; 157 return manager_;
155 } 158 }
156 159
157 private: 160 private:
158 base::scoped_nsprotocol<id<NativeAppWhitelistManager>> manager_; 161 base::scoped_nsprotocol<id<NativeAppWhitelistManager>> manager_;
159 }; 162 };
160 163
161 class TabTest : public BlockCleanupTest { 164 class TabTest : public BlockCleanupTest {
162 public: 165 public:
163 TabTest() : thread_bundle_(web::TestWebThreadBundle::REAL_FILE_THREAD) {} 166 TabTest()
167 : thread_bundle_(web::TestWebThreadBundle::REAL_FILE_THREAD),
168 scoped_browser_state_manager_(
169 base::MakeUnique<TestChromeBrowserStateManager>(base::FilePath())) {
170 }
164 171
165 void SetUp() override { 172 void SetUp() override {
166 BlockCleanupTest::SetUp(); 173 BlockCleanupTest::SetUp();
167 174
168 [[ChromeAppConstants sharedInstance] 175 [[ChromeAppConstants sharedInstance]
169 setCallbackSchemeForTesting:@"chromium"]; 176 setCallbackSchemeForTesting:@"chromium"];
170 177
171 // Set up the testing profiles. 178 // Set up the testing profiles.
172 TestChromeBrowserState::Builder test_cbs_builder; 179 TestChromeBrowserState::Builder test_cbs_builder;
173 chrome_browser_state_ = test_cbs_builder.Build(); 180 chrome_browser_state_ = test_cbs_builder.Build();
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 NSLog(@"title = %@; url = %@", base::SysUTF16ToNSString(result->title()), 310 NSLog(@"title = %@; url = %@", base::SysUTF16ToNSString(result->title()),
304 base::SysUTF8ToNSString(result->url().spec())); 311 base::SysUTF8ToNSString(result->url().spec()));
305 } 312 }
306 } 313 }
307 #endif 314 #endif
308 315
309 virtual bool UseOffTheRecordBrowserState() const { return false; } 316 virtual bool UseOffTheRecordBrowserState() const { return false; }
310 317
311 protected: 318 protected:
312 web::TestWebThreadBundle thread_bundle_; 319 web::TestWebThreadBundle thread_bundle_;
313 IOSChromeScopedTestingLocalState local_state_; 320 IOSChromeScopedTestingChromeBrowserStateManager scoped_browser_state_manager_;
314 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; 321 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
315 base::scoped_nsobject<Tab> tab_; 322 base::scoped_nsobject<Tab> tab_;
316 history::HistoryService* history_service_; // weak 323 history::HistoryService* history_service_; // weak
317 CRWWebController* mock_web_controller_; // weak 324 CRWWebController* mock_web_controller_; // weak
318 base::scoped_nsobject<UIView> web_controller_view_; 325 base::scoped_nsobject<UIView> web_controller_view_;
319 base::scoped_nsobject<ArrayTabModel> tabModel_; 326 base::scoped_nsobject<ArrayTabModel> tabModel_;
320 base::scoped_nsobject<id> mock_external_app_launcher_; 327 base::scoped_nsobject<id> mock_external_app_launcher_;
321 }; 328 };
322 329
323 TEST_F(TabTest, AddToHistoryWithRedirect) { 330 TEST_F(TabTest, AddToHistoryWithRedirect) {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 base::scoped_nsobject<FakeNativeAppMetadata> metadata( 549 base::scoped_nsobject<FakeNativeAppMetadata> metadata(
543 [[FakeNativeAppMetadata alloc] init]); 550 [[FakeNativeAppMetadata alloc] init]);
544 551
545 // Turn auto open on. 552 // Turn auto open on.
546 [metadata setShouldAutoOpenLinks:YES]; 553 [metadata setShouldAutoOpenLinks:YES];
547 int expectedCallCount = 2; 554 int expectedCallCount = 2;
548 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO); 555 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO);
549 EXPECT_FALSE([metadata shouldAutoOpenLinks]); 556 EXPECT_FALSE([metadata shouldAutoOpenLinks]);
550 } 557 }
551 558
552 class TestRequestGroupID : public BlockCleanupTest {
553 public:
554 void SetUp() override { BlockCleanupTest::SetUp(); }
555 void TearDown() override { BlockCleanupTest::TearDown(); }
556 };
557
558 } // namespace 559 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab_model_unittest.mm ('k') | ios/chrome/browser/test/perf_test_with_bvc_ios.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698