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/ui/tabs/tab_strip_model.h" | 5 #include "chrome/browser/ui/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/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/defaults.h" | 20 #include "chrome/browser/defaults.h" |
21 #include "chrome/browser/extensions/extension_tab_helper.h" | 21 #include "chrome/browser/extensions/extension_tab_helper.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_tabstrip.h" |
24 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 25 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
25 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 26 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
26 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h" | 27 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h" |
27 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" | 28 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" |
28 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 29 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
29 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
30 #include "chrome/common/extensions/extension.h" | 31 #include "chrome/common/extensions/extension.h" |
31 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
32 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 33 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
33 #include "chrome/test/base/testing_profile.h" | 34 #include "chrome/test/base/testing_profile.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 116 |
116 DISALLOW_COPY_AND_ASSIGN(TabStripDummyDelegate); | 117 DISALLOW_COPY_AND_ASSIGN(TabStripDummyDelegate); |
117 }; | 118 }; |
118 | 119 |
119 class TabStripModelTest : public ChromeRenderViewHostTestHarness { | 120 class TabStripModelTest : public ChromeRenderViewHostTestHarness { |
120 public: | 121 public: |
121 TabStripModelTest() : browser_thread_(BrowserThread::UI, &message_loop_) { | 122 TabStripModelTest() : browser_thread_(BrowserThread::UI, &message_loop_) { |
122 } | 123 } |
123 | 124 |
124 TabContents* CreateTabContents() { | 125 TabContents* CreateTabContents() { |
125 return Browser::TabContentsFactory( | 126 return chrome::TabContentsFactory( |
126 profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); | 127 profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); |
127 } | 128 } |
128 | 129 |
129 TabContents* CreateTabContentsWithSharedRPH( | 130 TabContents* CreateTabContentsWithSharedRPH( |
130 WebContents* web_contents) { | 131 WebContents* web_contents) { |
131 TabContents* retval = Browser::TabContentsFactory(profile(), | 132 TabContents* retval = chrome::TabContentsFactory(profile(), |
132 web_contents->GetRenderViewHost()->GetSiteInstance(), MSG_ROUTING_NONE, | 133 web_contents->GetRenderViewHost()->GetSiteInstance(), MSG_ROUTING_NONE, |
133 NULL, NULL); | 134 NULL, NULL); |
134 EXPECT_EQ(retval->web_contents()->GetRenderProcessHost(), | 135 EXPECT_EQ(retval->web_contents()->GetRenderProcessHost(), |
135 web_contents->GetRenderProcessHost()); | 136 web_contents->GetRenderProcessHost()); |
136 return retval; | 137 return retval; |
137 } | 138 } |
138 | 139 |
139 // Forwards a URL "load" request through to our dummy TabContents | 140 // Forwards a URL "load" request through to our dummy TabContents |
140 // implementation. | 141 // implementation. |
141 void LoadURL(WebContents* con, const std::wstring& url) { | 142 void LoadURL(WebContents* con, const std::wstring& url) { |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 observer.ClearStates(); | 564 observer.ClearStates(); |
564 } | 565 } |
565 | 566 |
566 // Test Getters | 567 // Test Getters |
567 { | 568 { |
568 EXPECT_EQ(contents2, tabstrip.GetActiveTabContents()); | 569 EXPECT_EQ(contents2, tabstrip.GetActiveTabContents()); |
569 EXPECT_EQ(contents2, tabstrip.GetTabContentsAt(0)); | 570 EXPECT_EQ(contents2, tabstrip.GetTabContentsAt(0)); |
570 EXPECT_EQ(contents1, tabstrip.GetTabContentsAt(1)); | 571 EXPECT_EQ(contents1, tabstrip.GetTabContentsAt(1)); |
571 EXPECT_EQ(0, tabstrip.GetIndexOfTabContents(contents2)); | 572 EXPECT_EQ(0, tabstrip.GetIndexOfTabContents(contents2)); |
572 EXPECT_EQ(1, tabstrip.GetIndexOfTabContents(contents1)); | 573 EXPECT_EQ(1, tabstrip.GetIndexOfTabContents(contents1)); |
573 EXPECT_EQ(0, tabstrip.GetIndexOfController( | 574 EXPECT_EQ(0, tabstrip.GetIndexOfWebContents(contents2->web_contents())); |
574 &contents2->web_contents()->GetController())); | 575 EXPECT_EQ(1, tabstrip.GetIndexOfWebContents(contents1->web_contents())); |
575 EXPECT_EQ(1, tabstrip.GetIndexOfController( | |
576 &contents1->web_contents()->GetController())); | |
577 } | 576 } |
578 | 577 |
579 // Test UpdateTabContentsStateAt | 578 // Test UpdateTabContentsStateAt |
580 { | 579 { |
581 tabstrip.UpdateTabContentsStateAt(0, TabStripModelObserver::ALL); | 580 tabstrip.UpdateTabContentsStateAt(0, TabStripModelObserver::ALL); |
582 EXPECT_EQ(1, observer.GetStateCount()); | 581 EXPECT_EQ(1, observer.GetStateCount()); |
583 State s1(contents2, 0, MockTabStripModelObserver::CHANGE); | 582 State s1(contents2, 0, MockTabStripModelObserver::CHANGE); |
584 EXPECT_TRUE(observer.StateEquals(0, s1)); | 583 EXPECT_TRUE(observer.StateEquals(0, s1)); |
585 observer.ClearStates(); | 584 observer.ClearStates(); |
586 } | 585 } |
(...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2414 ASSERT_EQ(1, observer.GetStateCount()); | 2413 ASSERT_EQ(1, observer.GetStateCount()); |
2415 MockTabStripModelObserver::State s( | 2414 MockTabStripModelObserver::State s( |
2416 contents2, 1, MockTabStripModelObserver::SELECT); | 2415 contents2, 1, MockTabStripModelObserver::SELECT); |
2417 s.src_contents = contents2; | 2416 s.src_contents = contents2; |
2418 s.src_index = 1; | 2417 s.src_index = 1; |
2419 s.user_gesture = false; | 2418 s.user_gesture = false; |
2420 EXPECT_TRUE(observer.StateEquals(0, s)); | 2419 EXPECT_TRUE(observer.StateEquals(0, s)); |
2421 strip.RemoveObserver(&observer); | 2420 strip.RemoveObserver(&observer); |
2422 strip.CloseAllTabs(); | 2421 strip.CloseAllTabs(); |
2423 } | 2422 } |
OLD | NEW |