OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
8 #include "chrome/browser/dock_info.h" | 8 #include "chrome/browser/dock_info.h" |
9 #include "chrome/browser/dom_ui/new_tab_ui.h" | 9 #include "chrome/browser/dom_ui/new_tab_ui.h" |
10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 class TabStripModelTest : public RenderViewHostTestHarness { | 74 class TabStripModelTest : public RenderViewHostTestHarness { |
75 public: | 75 public: |
76 TabContents* CreateTabContents() { | 76 TabContents* CreateTabContents() { |
77 return new TabContents(profile(), NULL, 0, NULL); | 77 return new TabContents(profile(), NULL, 0, NULL); |
78 } | 78 } |
79 | 79 |
80 // Forwards a URL "load" request through to our dummy TabContents | 80 // Forwards a URL "load" request through to our dummy TabContents |
81 // implementation. | 81 // implementation. |
82 void LoadURL(TabContents* con, const std::wstring& url) { | 82 void LoadURL(TabContents* con, const std::wstring& url) { |
83 controller().LoadURL(GURL(url), GURL(), PageTransition::LINK); | 83 controller().LoadURL(GURL(WideToUTF16(url)), GURL(), PageTransition::LINK); |
84 } | 84 } |
85 | 85 |
86 void GoBack(TabContents* contents) { | 86 void GoBack(TabContents* contents) { |
87 controller().GoBack(); | 87 controller().GoBack(); |
88 } | 88 } |
89 | 89 |
90 void GoForward(TabContents* contents) { | 90 void GoForward(TabContents* contents) { |
91 controller().GoForward(); | 91 controller().GoForward(); |
92 } | 92 } |
93 | 93 |
(...skipping 24 matching lines...) Expand all Loading... |
118 }; | 118 }; |
119 | 119 |
120 struct State { | 120 struct State { |
121 State(TabContents* a_dst_contents, | 121 State(TabContents* a_dst_contents, |
122 int a_dst_index, | 122 int a_dst_index, |
123 TabStripModelObserverAction a_action) | 123 TabStripModelObserverAction a_action) |
124 : src_contents(NULL), | 124 : src_contents(NULL), |
125 dst_contents(a_dst_contents), | 125 dst_contents(a_dst_contents), |
126 src_index(-1), | 126 src_index(-1), |
127 dst_index(a_dst_index), | 127 dst_index(a_dst_index), |
128 action(a_action), | |
129 user_gesture(false), | 128 user_gesture(false), |
130 foreground(false) { | 129 foreground(false), |
| 130 action(a_action) { |
131 } | 131 } |
132 | 132 |
133 TabContents* src_contents; | 133 TabContents* src_contents; |
134 TabContents* dst_contents; | 134 TabContents* dst_contents; |
135 int src_index; | 135 int src_index; |
136 int dst_index; | 136 int dst_index; |
137 bool user_gesture; | 137 bool user_gesture; |
138 bool foreground; | 138 bool foreground; |
139 TabStripModelObserverAction action; | 139 TabStripModelObserverAction action; |
140 }; | 140 }; |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 // is selected | 597 // is selected |
598 // If there are no other tabs that have the same opener, | 598 // If there are no other tabs that have the same opener, |
599 // The opener is selected | 599 // The opener is selected |
600 // | 600 // |
601 TEST_F(TabStripModelTest, TestSelectOnClose) { | 601 TEST_F(TabStripModelTest, TestSelectOnClose) { |
602 TabStripDummyDelegate delegate(NULL); | 602 TabStripDummyDelegate delegate(NULL); |
603 TabStripModel tabstrip(&delegate, profile()); | 603 TabStripModel tabstrip(&delegate, profile()); |
604 EXPECT_TRUE(tabstrip.empty()); | 604 EXPECT_TRUE(tabstrip.empty()); |
605 | 605 |
606 TabContents* opener_contents = CreateTabContents(); | 606 TabContents* opener_contents = CreateTabContents(); |
607 NavigationController* opener = &opener_contents->controller(); | |
608 tabstrip.AppendTabContents(opener_contents, true); | 607 tabstrip.AppendTabContents(opener_contents, true); |
609 | 608 |
610 TabContents* contents1 = CreateTabContents(); | 609 TabContents* contents1 = CreateTabContents(); |
611 TabContents* contents2 = CreateTabContents(); | 610 TabContents* contents2 = CreateTabContents(); |
612 TabContents* contents3 = CreateTabContents(); | 611 TabContents* contents3 = CreateTabContents(); |
613 | 612 |
614 // Note that we use Detach instead of Close throughout this test to avoid | 613 // Note that we use Detach instead of Close throughout this test to avoid |
615 // having to keep reconstructing these TabContentses. | 614 // having to keep reconstructing these TabContentses. |
616 | 615 |
617 // First test that closing tabs that are in the background doesn't adjust the | 616 // First test that closing tabs that are in the background doesn't adjust the |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 // - Close Tab | 674 // - Close Tab |
676 // - Close Other Tabs | 675 // - Close Other Tabs |
677 // - Close Tabs To Right | 676 // - Close Tabs To Right |
678 // - Close Tabs Opened By | 677 // - Close Tabs Opened By |
679 TEST_F(TabStripModelTest, TestContextMenuCloseCommands) { | 678 TEST_F(TabStripModelTest, TestContextMenuCloseCommands) { |
680 TabStripDummyDelegate delegate(NULL); | 679 TabStripDummyDelegate delegate(NULL); |
681 TabStripModel tabstrip(&delegate, profile()); | 680 TabStripModel tabstrip(&delegate, profile()); |
682 EXPECT_TRUE(tabstrip.empty()); | 681 EXPECT_TRUE(tabstrip.empty()); |
683 | 682 |
684 TabContents* opener_contents = CreateTabContents(); | 683 TabContents* opener_contents = CreateTabContents(); |
685 NavigationController* opener = &opener_contents->controller(); | |
686 tabstrip.AppendTabContents(opener_contents, true); | 684 tabstrip.AppendTabContents(opener_contents, true); |
687 | 685 |
688 TabContents* contents1 = CreateTabContents(); | 686 TabContents* contents1 = CreateTabContents(); |
689 TabContents* contents2 = CreateTabContents(); | 687 TabContents* contents2 = CreateTabContents(); |
690 TabContents* contents3 = CreateTabContents(); | 688 TabContents* contents3 = CreateTabContents(); |
691 | 689 |
692 InsertTabContentses(&tabstrip, contents1, contents2, contents3); | 690 InsertTabContentses(&tabstrip, contents1, contents2, contents3); |
693 EXPECT_EQ(0, tabstrip.selected_index()); | 691 EXPECT_EQ(0, tabstrip.selected_index()); |
694 | 692 |
695 tabstrip.ExecuteContextMenuCommand(2, TabStripModel::CommandCloseTab); | 693 tabstrip.ExecuteContextMenuCommand(2, TabStripModel::CommandCloseTab); |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 | 1200 |
1203 // Now select the last tab. | 1201 // Now select the last tab. |
1204 strip.SelectTabContentsAt(strip.count() - 1, true); | 1202 strip.SelectTabContentsAt(strip.count() - 1, true); |
1205 | 1203 |
1206 // Now close the last tab. The next adjacent should be selected. | 1204 // Now close the last tab. The next adjacent should be selected. |
1207 strip.CloseTabContentsAt(strip.count() - 1); | 1205 strip.CloseTabContentsAt(strip.count() - 1); |
1208 EXPECT_EQ(page_d_contents, strip.GetTabContentsAt(strip.selected_index())); | 1206 EXPECT_EQ(page_d_contents, strip.GetTabContentsAt(strip.selected_index())); |
1209 | 1207 |
1210 strip.CloseAllTabs(); | 1208 strip.CloseAllTabs(); |
1211 } | 1209 } |
OLD | NEW |