OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/tabs/tab_strip_model.h" | 5 #include "chrome/browser/tabs/tab_strip_model.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/property_bag.h" | 14 #include "base/property_bag.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
17 #include "base/string_split.h" | 17 #include "base/string_split.h" |
18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
19 #include "base/synchronization/waitable_event.h" | |
19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/defaults.h" | 21 #include "chrome/browser/defaults.h" |
21 #include "chrome/browser/extensions/extension_tab_helper.h" | 22 #include "chrome/browser/extensions/extension_tab_helper.h" |
22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/tabs/tab_strip_model_delegate.h" | 24 #include "chrome/browser/tabs/tab_strip_model_delegate.h" |
24 #include "chrome/browser/tabs/tab_strip_model_order_controller.h" | 25 #include "chrome/browser/tabs/tab_strip_model_order_controller.h" |
25 #include "chrome/browser/tabs/test_tab_strip_model_delegate.h" | 26 #include "chrome/browser/tabs/test_tab_strip_model_delegate.h" |
26 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
28 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 29 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 bool can_close_; | 125 bool can_close_; |
125 | 126 |
126 // Whether to report that we need to run an unload listener before closing. | 127 // Whether to report that we need to run an unload listener before closing. |
127 bool run_unload_; | 128 bool run_unload_; |
128 | 129 |
129 DISALLOW_COPY_AND_ASSIGN(TabStripDummyDelegate); | 130 DISALLOW_COPY_AND_ASSIGN(TabStripDummyDelegate); |
130 }; | 131 }; |
131 | 132 |
132 class TabStripModelTest : public ChromeRenderViewHostTestHarness { | 133 class TabStripModelTest : public ChromeRenderViewHostTestHarness { |
133 public: | 134 public: |
134 TabStripModelTest() : browser_thread_(BrowserThread::UI, &message_loop_) { | 135 TabStripModelTest() |
136 : browser_thread_(BrowserThread::UI, &message_loop_), | |
sky
2012/04/17 20:45:51
Promote this code to either ChromeRenderViewHostTe
GeorgeY
2012/04/17 20:52:25
Done already - forgot about this test - it is reve
| |
137 db_thread_(BrowserThread::DB) { | |
138 db_thread_.Start(); | |
139 } | |
140 | |
141 ~TabStripModelTest() { | |
142 // Schedule another task on the DB thread to notify us that it's safe to | |
143 // carry on with the test. | |
144 base::WaitableEvent done(false, false); | |
145 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | |
146 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); | |
147 done.Wait(); | |
148 db_thread_.Stop(); | |
135 } | 149 } |
136 | 150 |
137 TabContentsWrapper* CreateTabContents() { | 151 TabContentsWrapper* CreateTabContents() { |
138 return Browser::TabContentsFactory( | 152 return Browser::TabContentsFactory( |
139 profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); | 153 profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); |
140 } | 154 } |
141 | 155 |
142 TabContentsWrapper* CreateTabContentsWithSharedRPH( | 156 TabContentsWrapper* CreateTabContentsWithSharedRPH( |
143 WebContents* web_contents) { | 157 WebContents* web_contents) { |
144 TabContentsWrapper* retval = Browser::TabContentsFactory(profile(), | 158 TabContentsWrapper* retval = Browser::TabContentsFactory(profile(), |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 model->SetSelectionFromModel(selection_model); | 252 model->SetSelectionFromModel(selection_model); |
239 } | 253 } |
240 | 254 |
241 private: | 255 private: |
242 base::PropertyAccessor<int>* GetIDAccessor() { | 256 base::PropertyAccessor<int>* GetIDAccessor() { |
243 static base::PropertyAccessor<int> accessor; | 257 static base::PropertyAccessor<int> accessor; |
244 return &accessor; | 258 return &accessor; |
245 } | 259 } |
246 | 260 |
247 content::TestBrowserThread browser_thread_; | 261 content::TestBrowserThread browser_thread_; |
262 content::TestBrowserThread db_thread_; | |
248 | 263 |
249 std::wstring test_dir_; | 264 std::wstring test_dir_; |
250 std::wstring profile_path_; | 265 std::wstring profile_path_; |
251 }; | 266 }; |
252 | 267 |
253 class MockTabStripModelObserver : public TabStripModelObserver { | 268 class MockTabStripModelObserver : public TabStripModelObserver { |
254 public: | 269 public: |
255 MockTabStripModelObserver() | 270 MockTabStripModelObserver() |
256 : empty_(true), | 271 : empty_(true), |
257 model_(NULL) {} | 272 model_(NULL) {} |
(...skipping 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2440 ASSERT_EQ(1, observer.GetStateCount()); | 2455 ASSERT_EQ(1, observer.GetStateCount()); |
2441 MockTabStripModelObserver::State s( | 2456 MockTabStripModelObserver::State s( |
2442 contents2, 1, MockTabStripModelObserver::SELECT); | 2457 contents2, 1, MockTabStripModelObserver::SELECT); |
2443 s.src_contents = contents2; | 2458 s.src_contents = contents2; |
2444 s.src_index = 1; | 2459 s.src_index = 1; |
2445 s.user_gesture = false; | 2460 s.user_gesture = false; |
2446 EXPECT_TRUE(observer.StateEquals(0, s)); | 2461 EXPECT_TRUE(observer.StateEquals(0, s)); |
2447 strip.RemoveObserver(&observer); | 2462 strip.RemoveObserver(&observer); |
2448 strip.CloseAllTabs(); | 2463 strip.CloseAllTabs(); |
2449 } | 2464 } |
OLD | NEW |