| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 337 |
| 338 // TabStripModelObserver implementation: | 338 // TabStripModelObserver implementation: |
| 339 virtual void TabInsertedAt(TabContentsWrapper* contents, | 339 virtual void TabInsertedAt(TabContentsWrapper* contents, |
| 340 int index, | 340 int index, |
| 341 bool foreground) { | 341 bool foreground) { |
| 342 empty_ = false; | 342 empty_ = false; |
| 343 State* s = new State(contents, index, INSERT); | 343 State* s = new State(contents, index, INSERT); |
| 344 s->foreground = foreground; | 344 s->foreground = foreground; |
| 345 states_.push_back(s); | 345 states_.push_back(s); |
| 346 } | 346 } |
| 347 virtual void TabSelectedAt(TabContentsWrapper* old_contents, | 347 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, |
| 348 TabContentsWrapper* new_contents, | 348 TabContentsWrapper* new_contents, |
| 349 int index, | 349 int index, |
| 350 bool user_gesture) { | 350 bool user_gesture) { |
| 351 State* s = new State(new_contents, index, SELECT); | 351 State* s = new State(new_contents, index, SELECT); |
| 352 s->src_contents = old_contents; | 352 s->src_contents = old_contents; |
| 353 s->user_gesture = user_gesture; | 353 s->user_gesture = user_gesture; |
| 354 states_.push_back(s); | 354 states_.push_back(s); |
| 355 } | 355 } |
| 356 virtual void TabMoved( | 356 virtual void TabMoved( |
| 357 TabContentsWrapper* contents, int from_index, int to_index) { | 357 TabContentsWrapper* contents, int from_index, int to_index) { |
| 358 State* s = new State(contents, to_index, MOVE); | 358 State* s = new State(contents, to_index, MOVE); |
| 359 s->src_index = from_index; | 359 s->src_index = from_index; |
| 360 states_.push_back(s); | 360 states_.push_back(s); |
| (...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2176 strip.AppendTabContents(contents3, true); | 2176 strip.AppendTabContents(contents3, true); |
| 2177 strip.ToggleSelectionAt(1); | 2177 strip.ToggleSelectionAt(1); |
| 2178 strip.CloseSelectedTabs(); | 2178 strip.CloseSelectedTabs(); |
| 2179 EXPECT_EQ(1, strip.count()); | 2179 EXPECT_EQ(1, strip.count()); |
| 2180 EXPECT_EQ(0, strip.active_index()); | 2180 EXPECT_EQ(0, strip.active_index()); |
| 2181 strip.CloseAllTabs(); | 2181 strip.CloseAllTabs(); |
| 2182 } | 2182 } |
| 2183 | 2183 |
| 2184 // Verifies that if we change the selection from a multi selection to a single | 2184 // Verifies that if we change the selection from a multi selection to a single |
| 2185 // selection, but not in a way that changes the selected_index that | 2185 // selection, but not in a way that changes the selected_index that |
| 2186 // TabSelectedAt is still invoked. | 2186 // ActiveTabChanged is still invoked. |
| 2187 TEST_F(TabStripModelTest, MultipleToSingle) { | 2187 TEST_F(TabStripModelTest, MultipleToSingle) { |
| 2188 TabStripDummyDelegate delegate(NULL); | 2188 TabStripDummyDelegate delegate(NULL); |
| 2189 TabStripModel strip(&delegate, profile()); | 2189 TabStripModel strip(&delegate, profile()); |
| 2190 TabContentsWrapper* contents1 = CreateTabContents(); | 2190 TabContentsWrapper* contents1 = CreateTabContents(); |
| 2191 TabContentsWrapper* contents2 = CreateTabContents(); | 2191 TabContentsWrapper* contents2 = CreateTabContents(); |
| 2192 strip.AppendTabContents(contents1, false); | 2192 strip.AppendTabContents(contents1, false); |
| 2193 strip.AppendTabContents(contents2, false); | 2193 strip.AppendTabContents(contents2, false); |
| 2194 strip.ToggleSelectionAt(0); | 2194 strip.ToggleSelectionAt(0); |
| 2195 strip.ToggleSelectionAt(1); | 2195 strip.ToggleSelectionAt(1); |
| 2196 | 2196 |
| 2197 MockTabStripModelObserver observer; | 2197 MockTabStripModelObserver observer; |
| 2198 strip.AddObserver(&observer); | 2198 strip.AddObserver(&observer); |
| 2199 // This changes the selection (0 is no longer selected) but the selected_index | 2199 // This changes the selection (0 is no longer selected) but the selected_index |
| 2200 // still remains at 1. | 2200 // still remains at 1. |
| 2201 strip.ActivateTabAt(1, true); | 2201 strip.ActivateTabAt(1, true); |
| 2202 ASSERT_EQ(1, observer.GetStateCount()); | 2202 ASSERT_EQ(1, observer.GetStateCount()); |
| 2203 MockTabStripModelObserver::State s( | 2203 MockTabStripModelObserver::State s( |
| 2204 contents2, 1, MockTabStripModelObserver::SELECT); | 2204 contents2, 1, MockTabStripModelObserver::SELECT); |
| 2205 s.src_contents = contents2; | 2205 s.src_contents = contents2; |
| 2206 s.user_gesture = true; | 2206 s.user_gesture = true; |
| 2207 EXPECT_TRUE(observer.StateEquals(0, s)); | 2207 EXPECT_TRUE(observer.StateEquals(0, s)); |
| 2208 strip.RemoveObserver(&observer); | 2208 strip.RemoveObserver(&observer); |
| 2209 strip.CloseAllTabs(); | 2209 strip.CloseAllTabs(); |
| 2210 } | 2210 } |
| OLD | NEW |