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

Side by Side Diff: ios/chrome/browser/ui/main/browser_view_wrangler_unittest.mm

Issue 2632393002: Allow using a BrowserViewController without BookmarkModel for testing. (Closed)
Patch Set: 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
« no previous file with comments | « ios/chrome/browser/ui/browser_view_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/chrome/browser/ui/main/browser_view_wrangler.h" 5 #import "ios/chrome/browser/ui/main/browser_view_wrangler.h"
6 6
7 #import <UIKit/UIKit.h> 7 #import <UIKit/UIKit.h>
8 8
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "components/bookmarks/test/bookmark_test_helpers.h"
11 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" 10 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
13 #import "ios/chrome/browser/tabs/tab_model.h" 11 #import "ios/chrome/browser/tabs/tab_model.h"
14 #import "ios/chrome/browser/ui/browser_view_controller.h" 12 #import "ios/chrome/browser/ui/browser_view_controller.h"
15 #include "ios/web/public/test/test_web_thread_bundle.h" 13 #include "ios/web/public/test/test_web_thread_bundle.h"
16 #include "testing/platform_test.h" 14 #include "testing/platform_test.h"
17 15
18 namespace { 16 namespace {
19 17
20 class BrowserViewWranglerTest : public PlatformTest { 18 class BrowserViewWranglerTest : public PlatformTest {
21 protected: 19 protected:
22 BrowserViewWranglerTest() { 20 BrowserViewWranglerTest() {
23 TestChromeBrowserState::Builder test_cbs_builder; 21 TestChromeBrowserState::Builder test_cbs_builder;
24 chrome_browser_state_ = test_cbs_builder.Build(); 22 chrome_browser_state_ = test_cbs_builder.Build();
25 chrome_browser_state_->CreateBookmarkModel(false);
26 bookmarks::BookmarkModel* bookmark_model =
27 ios::BookmarkModelFactory::GetForBrowserState(
28 chrome_browser_state_.get());
29 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model);
30 } 23 }
31 24
32 // SessionWindow, used to create the TabModel, needs to run on the web thread.
33 web::TestWebThreadBundle thread_bundle_; 25 web::TestWebThreadBundle thread_bundle_;
34 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; 26 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
35 }; 27 };
36 28
37 TEST_F(BrowserViewWranglerTest, TestInitNilObserver) { 29 TEST_F(BrowserViewWranglerTest, TestInitNilObserver) {
38 base::scoped_nsobject<BrowserViewWrangler> wrangler( 30 base::scoped_nsobject<BrowserViewWrangler> wrangler(
39 [[BrowserViewWrangler alloc] 31 [[BrowserViewWrangler alloc]
40 initWithBrowserState:chrome_browser_state_.get() 32 initWithBrowserState:chrome_browser_state_.get()
41 tabModelObserver:nil]); 33 tabModelObserver:nil]);
42 34
43 // Test that BVC and tab model are created on demand. 35 // Test that BVC and tab model are created on demand.
44 BrowserViewController* bvc = [wrangler mainBVC]; 36 BrowserViewController* bvc = [wrangler mainBVC];
45 EXPECT_NE(bvc, nil); 37 EXPECT_NE(bvc, nil);
46 38
47 TabModel* tabModel = [wrangler mainTabModel]; 39 TabModel* tabModel = [wrangler mainTabModel];
48 EXPECT_NE(tabModel, nil); 40 EXPECT_NE(tabModel, nil);
49 41
50 // Test that once created the BVC and tab model aren't re-created. 42 // Test that once created the BVC and tab model aren't re-created.
51 EXPECT_EQ(bvc, [wrangler mainBVC]); 43 EXPECT_EQ(bvc, [wrangler mainBVC]);
52 EXPECT_EQ(tabModel, [wrangler mainTabModel]); 44 EXPECT_EQ(tabModel, [wrangler mainTabModel]);
53 45
54 // Test that the OTR objects are (a) OTR and (b) not the same as the non-OTR 46 // Test that the OTR objects are (a) OTR and (b) not the same as the non-OTR
55 // objects. 47 // objects.
56 EXPECT_NE(bvc, [wrangler otrBVC]); 48 EXPECT_NE(bvc, [wrangler otrBVC]);
57 EXPECT_NE(tabModel, [wrangler otrTabModel]); 49 EXPECT_NE(tabModel, [wrangler otrTabModel]);
58 EXPECT_TRUE([wrangler otrTabModel].browserState->IsOffTheRecord()); 50 EXPECT_TRUE([wrangler otrTabModel].browserState->IsOffTheRecord());
59 } 51 }
60 52
61 } // namespace 53 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/browser_view_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698