OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/chrome/browser/ui/main/browser_view_wrangler.h" |
| 6 |
| 7 #include <UIKit/UIKit.h> |
| 8 |
| 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" |
| 13 #import "ios/chrome/browser/tabs/tab_model.h" |
| 14 #import "ios/chrome/browser/ui/browser_view_controller.h" |
| 15 #include "ios/web/public/test/test_web_thread_bundle.h" |
| 16 #include "testing/platform_test.h" |
| 17 |
| 18 namespace { |
| 19 |
| 20 class BrowserViewWranglerTest : public PlatformTest { |
| 21 protected: |
| 22 BrowserViewWranglerTest() { |
| 23 TestChromeBrowserState::Builder test_cbs_builder; |
| 24 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 } |
| 31 |
| 32 // SessionWindow, used to create the TabModel, needs to run on the web thread. |
| 33 web::TestWebThreadBundle thread_bundle_; |
| 34 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; |
| 35 }; |
| 36 |
| 37 TEST_F(BrowserViewWranglerTest, TestInitNilObserver) { |
| 38 base::scoped_nsobject<BrowserViewWrangler> wrangler( |
| 39 [[BrowserViewWrangler alloc] |
| 40 initWithBrowserState:chrome_browser_state_.get() |
| 41 tabModelObserver:nil]); |
| 42 |
| 43 // Test that BVC and tab model are created on demand. |
| 44 BrowserViewController* bvc = [wrangler mainBVC]; |
| 45 EXPECT_NE(bvc, nil); |
| 46 |
| 47 TabModel* tabModel = [wrangler mainTabModel]; |
| 48 EXPECT_NE(tabModel, nil); |
| 49 |
| 50 // Test that once created the BVC and tab model aren't re-created. |
| 51 EXPECT_EQ(bvc, [wrangler mainBVC]); |
| 52 EXPECT_EQ(tabModel, [wrangler mainTabModel]); |
| 53 |
| 54 // Test that the OTR objects are (a) OTR and (b) not the same as the non-OTR |
| 55 // objects. |
| 56 EXPECT_NE(bvc, [wrangler otrBVC]); |
| 57 EXPECT_NE(tabModel, [wrangler otrTabModel]); |
| 58 EXPECT_TRUE([wrangler otrTabModel].browserState->IsOffTheRecord()); |
| 59 } |
| 60 |
| 61 } // namespace |
OLD | NEW |