OLD | NEW |
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" | |
10 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 9 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
11 #import "ios/chrome/browser/tabs/tab_model.h" | 10 #import "ios/chrome/browser/tabs/tab_model.h" |
12 #import "ios/chrome/browser/ui/browser_view_controller.h" | 11 #import "ios/chrome/browser/ui/browser_view_controller.h" |
13 #include "ios/web/public/test/test_web_thread_bundle.h" | 12 #include "ios/web/public/test/test_web_thread_bundle.h" |
14 #include "testing/platform_test.h" | 13 #include "testing/platform_test.h" |
15 | 14 |
| 15 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 16 #error "This file requires ARC support." |
| 17 #endif |
| 18 |
16 namespace { | 19 namespace { |
17 | 20 |
18 class BrowserViewWranglerTest : public PlatformTest { | 21 class BrowserViewWranglerTest : public PlatformTest { |
19 protected: | 22 protected: |
20 BrowserViewWranglerTest() { | 23 BrowserViewWranglerTest() { |
21 TestChromeBrowserState::Builder test_cbs_builder; | 24 TestChromeBrowserState::Builder test_cbs_builder; |
22 chrome_browser_state_ = test_cbs_builder.Build(); | 25 chrome_browser_state_ = test_cbs_builder.Build(); |
23 } | 26 } |
24 | 27 |
25 web::TestWebThreadBundle thread_bundle_; | 28 web::TestWebThreadBundle thread_bundle_; |
26 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; | 29 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; |
27 }; | 30 }; |
28 | 31 |
29 TEST_F(BrowserViewWranglerTest, TestInitNilObserver) { | 32 TEST_F(BrowserViewWranglerTest, TestInitNilObserver) { |
30 base::scoped_nsobject<BrowserViewWrangler> wrangler( | 33 BrowserViewWrangler* wrangler = [[BrowserViewWrangler alloc] |
31 [[BrowserViewWrangler alloc] | 34 initWithBrowserState:chrome_browser_state_.get() |
32 initWithBrowserState:chrome_browser_state_.get() | 35 tabModelObserver:nil]; |
33 tabModelObserver:nil]); | |
34 | 36 |
35 // Test that BVC and tab model are created on demand. | 37 // Test that BVC and tab model are created on demand. |
36 BrowserViewController* bvc = [wrangler mainBVC]; | 38 BrowserViewController* bvc = [wrangler mainBVC]; |
37 EXPECT_NE(bvc, nil); | 39 EXPECT_NE(bvc, nil); |
38 | 40 |
39 TabModel* tabModel = [wrangler mainTabModel]; | 41 TabModel* tabModel = [wrangler mainTabModel]; |
40 EXPECT_NE(tabModel, nil); | 42 EXPECT_NE(tabModel, nil); |
41 | 43 |
42 // Test that once created the BVC and tab model aren't re-created. | 44 // Test that once created the BVC and tab model aren't re-created. |
43 EXPECT_EQ(bvc, [wrangler mainBVC]); | 45 EXPECT_EQ(bvc, [wrangler mainBVC]); |
44 EXPECT_EQ(tabModel, [wrangler mainTabModel]); | 46 EXPECT_EQ(tabModel, [wrangler mainTabModel]); |
45 | 47 |
46 // Test that the OTR objects are (a) OTR and (b) not the same as the non-OTR | 48 // Test that the OTR objects are (a) OTR and (b) not the same as the non-OTR |
47 // objects. | 49 // objects. |
48 EXPECT_NE(bvc, [wrangler otrBVC]); | 50 EXPECT_NE(bvc, [wrangler otrBVC]); |
49 EXPECT_NE(tabModel, [wrangler otrTabModel]); | 51 EXPECT_NE(tabModel, [wrangler otrTabModel]); |
50 EXPECT_TRUE([wrangler otrTabModel].browserState->IsOffTheRecord()); | 52 EXPECT_TRUE([wrangler otrTabModel].browserState->IsOffTheRecord()); |
51 } | 53 } |
52 | 54 |
53 } // namespace | 55 } // namespace |
OLD | NEW |