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 #include "base/mac/scoped_nsautorelease_pool.h" | 5 #include "base/mac/scoped_nsautorelease_pool.h" |
6 #include "base/memory/ptr_util.h" | 6 #include "base/memory/ptr_util.h" |
7 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 7 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| 8 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h" |
8 #import "ios/chrome/browser/sessions/session_window.h" | 9 #import "ios/chrome/browser/sessions/session_window.h" |
9 #import "ios/chrome/browser/sessions/test_session_service.h" | 10 #import "ios/chrome/browser/sessions/test_session_service.h" |
10 #import "ios/chrome/browser/tabs/tab.h" | 11 #import "ios/chrome/browser/tabs/tab.h" |
11 #import "ios/chrome/browser/tabs/tab_model.h" | 12 #import "ios/chrome/browser/tabs/tab_model.h" |
12 #import "ios/chrome/browser/tabs/tab_model_order_controller.h" | 13 #import "ios/chrome/browser/tabs/tab_model_order_controller.h" |
| 14 #include "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager
.h" |
13 #include "ios/web/public/referrer.h" | 15 #include "ios/web/public/referrer.h" |
14 #include "ios/web/public/test/test_web_thread_bundle.h" | 16 #include "ios/web/public/test/test_web_thread_bundle.h" |
15 #include "ios/web/public/web_thread.h" | 17 #include "ios/web/public/web_thread.h" |
16 #include "testing/platform_test.h" | 18 #include "testing/platform_test.h" |
17 #import "third_party/ocmock/OCMock/OCMock.h" | 19 #import "third_party/ocmock/OCMock/OCMock.h" |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 class TabModelOrderControllerTest : public PlatformTest { | 23 class TabModelOrderControllerTest : public PlatformTest { |
22 protected: | 24 protected: |
23 TabModelOrderControllerTest() | 25 TabModelOrderControllerTest() |
24 : thread_bundle_(web::TestWebThreadBundle::IO_MAINLOOP) {} | 26 : thread_bundle_(web::TestWebThreadBundle::IO_MAINLOOP), |
| 27 scoped_browser_state_manager_( |
| 28 base::MakeUnique<TestChromeBrowserStateManager>(base::FilePath())) { |
| 29 } |
25 | 30 |
26 void SetUp() override { | 31 void SetUp() override { |
27 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 32 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
28 PlatformTest::SetUp(); | 33 PlatformTest::SetUp(); |
29 | 34 |
30 TestChromeBrowserState::Builder test_cbs_builder; | 35 TestChromeBrowserState::Builder test_cbs_builder; |
31 chrome_browser_state_ = test_cbs_builder.Build(); | 36 chrome_browser_state_ = test_cbs_builder.Build(); |
32 | 37 |
33 dummy_tab_.reset([[Tab alloc] | 38 dummy_tab_.reset([[Tab alloc] |
34 initWithWindowName:nil | 39 initWithWindowName:nil |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 windowName:nil | 76 windowName:nil |
72 opener:parentTab | 77 opener:parentTab |
73 openedByDOM:NO | 78 openedByDOM:NO |
74 atIndex:TabModelConstants::kTabPositionAutomatically | 79 atIndex:TabModelConstants::kTabPositionAutomatically |
75 inBackground:YES]; | 80 inBackground:YES]; |
76 } | 81 } |
77 | 82 |
78 GURL url_; | 83 GURL url_; |
79 web::Referrer referrer_; | 84 web::Referrer referrer_; |
80 web::TestWebThreadBundle thread_bundle_; | 85 web::TestWebThreadBundle thread_bundle_; |
| 86 IOSChromeScopedTestingChromeBrowserStateManager scoped_browser_state_manager_; |
81 base::scoped_nsobject<SessionWindowIOS> sessionWindow_; | 87 base::scoped_nsobject<SessionWindowIOS> sessionWindow_; |
82 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; | 88 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; |
83 base::scoped_nsobject<Tab> dummy_tab_; | 89 base::scoped_nsobject<Tab> dummy_tab_; |
84 base::scoped_nsobject<TabModelOrderController> orderController_; | 90 base::scoped_nsobject<TabModelOrderController> orderController_; |
85 base::scoped_nsobject<TabModel> tabModel_; | 91 base::scoped_nsobject<TabModel> tabModel_; |
86 base::mac::ScopedNSAutoreleasePool pool_; | 92 base::mac::ScopedNSAutoreleasePool pool_; |
87 }; | 93 }; |
88 | 94 |
89 // Verifies that tabs added in the background (e.g. from context menu -> Open in | 95 // Verifies that tabs added in the background (e.g. from context menu -> Open in |
90 // new tab) are inserted in the proper order. | 96 // new tab) are inserted in the proper order. |
(...skipping 18 matching lines...) Expand all Loading... |
109 // would be inserted before the child's child. | 115 // would be inserted before the child's child. |
110 addTabToParentInBackground(childTab); | 116 addTabToParentInBackground(childTab); |
111 index = [orderController_ | 117 index = [orderController_ |
112 insertionIndexForTab:dummy_tab_ | 118 insertionIndexForTab:dummy_tab_ |
113 transition:ui::PAGE_TRANSITION_LINK | 119 transition:ui::PAGE_TRANSITION_LINK |
114 opener:parentTab | 120 opener:parentTab |
115 adjacency:TabModelOrderConstants::kAdjacentAfter]; | 121 adjacency:TabModelOrderConstants::kAdjacentAfter]; |
116 EXPECT_EQ(2, index); | 122 EXPECT_EQ(2, index); |
117 } | 123 } |
118 } // anonymous namespace | 124 } // anonymous namespace |
OLD | NEW |