Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1480)

Side by Side Diff: chrome/browser/ui/tabs/tab_strip_model_unittest.cc

Issue 10937028: Do not discard selected tab (Closed) Base URL: http://git.chromium.org/chromium/src.git@new
Patch Set: handle active tab Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/tabs/tab_strip_model.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 2187 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 state2.src_contents = null_contents1; 2198 state2.src_contents = null_contents1;
2199 EXPECT_TRUE(tabstrip_observer.StateEquals(0, state2)); 2199 EXPECT_TRUE(tabstrip_observer.StateEquals(0, state2));
2200 tabstrip_observer.ClearStates(); 2200 tabstrip_observer.ClearStates();
2201 2201
2202 // Activating the tab should clear its discard state. 2202 // Activating the tab should clear its discard state.
2203 tabstrip.ActivateTabAt(0, true /* user_gesture */); 2203 tabstrip.ActivateTabAt(0, true /* user_gesture */);
2204 ASSERT_EQ(2, tabstrip.count()); 2204 ASSERT_EQ(2, tabstrip.count());
2205 EXPECT_FALSE(tabstrip.IsTabDiscarded(0)); 2205 EXPECT_FALSE(tabstrip.IsTabDiscarded(0));
2206 EXPECT_FALSE(tabstrip.IsTabDiscarded(1)); 2206 EXPECT_FALSE(tabstrip.IsTabDiscarded(1));
2207 2207
2208 // Discarding the active tab should not crash. 2208 // Don't discard active tab.
2209 TabContents* null_contents3 = tabstrip.DiscardTabContentsAt(0); 2209 tabstrip.DiscardTabContentsAt(0);
2210 ASSERT_EQ(2, tabstrip.count()); 2210 ASSERT_EQ(2, tabstrip.count());
2211 EXPECT_TRUE(tabstrip.IsTabDiscarded(0)); 2211 EXPECT_FALSE(tabstrip.IsTabDiscarded(0));
2212 EXPECT_FALSE(tabstrip.IsTabDiscarded(1)); 2212 EXPECT_FALSE(tabstrip.IsTabDiscarded(1));
2213 ASSERT_EQ(null_contents3, tabstrip.GetTabContentsAt(0));
2214 2213
2215 tabstrip.CloseAllTabs(); 2214 tabstrip.CloseAllTabs();
2216 } 2215 }
2217 2216
2218 // Makes sure TabStripModel handles the case of deleting a tab while removing 2217 // Makes sure TabStripModel handles the case of deleting a tab while removing
2219 // another tab. 2218 // another tab.
2220 TEST_F(TabStripModelTest, DeleteFromDestroy) { 2219 TEST_F(TabStripModelTest, DeleteFromDestroy) {
2221 TabStripDummyDelegate delegate(NULL); 2220 TabStripDummyDelegate delegate(NULL);
2222 TabStripModel strip(&delegate, profile()); 2221 TabStripModel strip(&delegate, profile());
2223 TabContents* contents1 = CreateTabContents(); 2222 TabContents* contents1 = CreateTabContents();
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2441 ASSERT_EQ(1, observer.GetStateCount()); 2440 ASSERT_EQ(1, observer.GetStateCount());
2442 MockTabStripModelObserver::State s( 2441 MockTabStripModelObserver::State s(
2443 contents2, 1, MockTabStripModelObserver::SELECT); 2442 contents2, 1, MockTabStripModelObserver::SELECT);
2444 s.src_contents = contents2; 2443 s.src_contents = contents2;
2445 s.src_index = 1; 2444 s.src_index = 1;
2446 s.user_gesture = false; 2445 s.user_gesture = false;
2447 EXPECT_TRUE(observer.StateEquals(0, s)); 2446 EXPECT_TRUE(observer.StateEquals(0, s));
2448 strip.RemoveObserver(&observer); 2447 strip.RemoveObserver(&observer);
2449 strip.CloseAllTabs(); 2448 strip.CloseAllTabs();
2450 } 2449 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tabs/tab_strip_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698