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

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

Issue 7134026: Multi-tab: Renaming TabStripModel::GetSelectedTabContents to GetActiveTabContents (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renaming in tab_strip_controller.mm too. Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/tabs/tab_strip_model_order_controller.cc ('k') | chrome/browser/ui/browser.h » ('j') | 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) 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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 s1.src_index = 1; 542 s1.src_index = 1;
543 EXPECT_TRUE(observer.StateEquals(0, s1)); 543 EXPECT_TRUE(observer.StateEquals(0, s1));
544 EXPECT_EQ(1, tabstrip.active_index()); 544 EXPECT_EQ(1, tabstrip.active_index());
545 545
546 tabstrip.MoveTabContentsAt(0, 1, false); 546 tabstrip.MoveTabContentsAt(0, 1, false);
547 observer.ClearStates(); 547 observer.ClearStates();
548 } 548 }
549 549
550 // Test Getters 550 // Test Getters
551 { 551 {
552 EXPECT_EQ(contents2, tabstrip.GetSelectedTabContents()); 552 EXPECT_EQ(contents2, tabstrip.GetActiveTabContents());
553 EXPECT_EQ(contents2, tabstrip.GetTabContentsAt(0)); 553 EXPECT_EQ(contents2, tabstrip.GetTabContentsAt(0));
554 EXPECT_EQ(contents1, tabstrip.GetTabContentsAt(1)); 554 EXPECT_EQ(contents1, tabstrip.GetTabContentsAt(1));
555 EXPECT_EQ(0, tabstrip.GetIndexOfTabContents(contents2)); 555 EXPECT_EQ(0, tabstrip.GetIndexOfTabContents(contents2));
556 EXPECT_EQ(1, tabstrip.GetIndexOfTabContents(contents1)); 556 EXPECT_EQ(1, tabstrip.GetIndexOfTabContents(contents1));
557 EXPECT_EQ(0, tabstrip.GetIndexOfController(&contents2->controller())); 557 EXPECT_EQ(0, tabstrip.GetIndexOfController(&contents2->controller()));
558 EXPECT_EQ(1, tabstrip.GetIndexOfController(&contents1->controller())); 558 EXPECT_EQ(1, tabstrip.GetIndexOfController(&contents1->controller()));
559 } 559 }
560 560
561 // Test UpdateTabContentsStateAt 561 // Test UpdateTabContentsStateAt
562 { 562 {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 // Now open a foreground tab from a link. It should be opened adjacent to the 787 // Now open a foreground tab from a link. It should be opened adjacent to the
788 // opener tab. 788 // opener tab.
789 TabContentsWrapper* fg_link_contents = CreateTabContents(); 789 TabContentsWrapper* fg_link_contents = CreateTabContents();
790 int insert_index = tabstrip.order_controller()->DetermineInsertionIndex( 790 int insert_index = tabstrip.order_controller()->DetermineInsertionIndex(
791 fg_link_contents, PageTransition::LINK, true); 791 fg_link_contents, PageTransition::LINK, true);
792 EXPECT_EQ(1, insert_index); 792 EXPECT_EQ(1, insert_index);
793 tabstrip.InsertTabContentsAt(insert_index, fg_link_contents, 793 tabstrip.InsertTabContentsAt(insert_index, fg_link_contents,
794 TabStripModel::ADD_ACTIVE | 794 TabStripModel::ADD_ACTIVE |
795 TabStripModel::ADD_INHERIT_GROUP); 795 TabStripModel::ADD_INHERIT_GROUP);
796 EXPECT_EQ(1, tabstrip.active_index()); 796 EXPECT_EQ(1, tabstrip.active_index());
797 EXPECT_EQ(fg_link_contents, tabstrip.GetSelectedTabContents()); 797 EXPECT_EQ(fg_link_contents, tabstrip.GetActiveTabContents());
798 798
799 // Now close this contents. The selection should move to the opener contents. 799 // Now close this contents. The selection should move to the opener contents.
800 tabstrip.CloseSelectedTabs(); 800 tabstrip.CloseSelectedTabs();
801 EXPECT_EQ(0, tabstrip.active_index()); 801 EXPECT_EQ(0, tabstrip.active_index());
802 802
803 // Now open a new empty tab. It should open at the end of the strip. 803 // Now open a new empty tab. It should open at the end of the strip.
804 TabContentsWrapper* fg_nonlink_contents = CreateTabContents(); 804 TabContentsWrapper* fg_nonlink_contents = CreateTabContents();
805 insert_index = tabstrip.order_controller()->DetermineInsertionIndex( 805 insert_index = tabstrip.order_controller()->DetermineInsertionIndex(
806 fg_nonlink_contents, PageTransition::AUTO_BOOKMARK, true); 806 fg_nonlink_contents, PageTransition::AUTO_BOOKMARK, true);
807 EXPECT_EQ(tabstrip.count(), insert_index); 807 EXPECT_EQ(tabstrip.count(), insert_index);
808 // We break the opener relationship... 808 // We break the opener relationship...
809 tabstrip.InsertTabContentsAt(insert_index, fg_nonlink_contents, 809 tabstrip.InsertTabContentsAt(insert_index, fg_nonlink_contents,
810 TabStripModel::ADD_NONE); 810 TabStripModel::ADD_NONE);
811 // Now select it, so that user_gesture == true causes the opener relationship 811 // Now select it, so that user_gesture == true causes the opener relationship
812 // to be forgotten... 812 // to be forgotten...
813 tabstrip.ActivateTabAt(tabstrip.count() - 1, true); 813 tabstrip.ActivateTabAt(tabstrip.count() - 1, true);
814 EXPECT_EQ(tabstrip.count() - 1, tabstrip.active_index()); 814 EXPECT_EQ(tabstrip.count() - 1, tabstrip.active_index());
815 EXPECT_EQ(fg_nonlink_contents, tabstrip.GetSelectedTabContents()); 815 EXPECT_EQ(fg_nonlink_contents, tabstrip.GetActiveTabContents());
816 816
817 // Verify that all opener relationships are forgotten. 817 // Verify that all opener relationships are forgotten.
818 EXPECT_EQ(-1, tabstrip.GetIndexOfNextTabContentsOpenedBy(opener, 2, false)); 818 EXPECT_EQ(-1, tabstrip.GetIndexOfNextTabContentsOpenedBy(opener, 2, false));
819 EXPECT_EQ(-1, tabstrip.GetIndexOfNextTabContentsOpenedBy(opener, 3, false)); 819 EXPECT_EQ(-1, tabstrip.GetIndexOfNextTabContentsOpenedBy(opener, 3, false));
820 EXPECT_EQ(-1, tabstrip.GetIndexOfNextTabContentsOpenedBy(opener, 3, false)); 820 EXPECT_EQ(-1, tabstrip.GetIndexOfNextTabContentsOpenedBy(opener, 3, false));
821 EXPECT_EQ(-1, tabstrip.GetIndexOfLastTabContentsOpenedBy(opener, 1)); 821 EXPECT_EQ(-1, tabstrip.GetIndexOfLastTabContentsOpenedBy(opener, 1));
822 822
823 tabstrip.CloseAllTabs(); 823 tabstrip.CloseAllTabs();
824 EXPECT_TRUE(tabstrip.empty()); 824 EXPECT_TRUE(tabstrip.empty());
825 } 825 }
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 TabContentsWrapper* contents3 = CreateTabContents(); 1096 TabContentsWrapper* contents3 = CreateTabContents();
1097 1097
1098 InsertTabContentses(&tabstrip, contents1, contents2, contents3); 1098 InsertTabContentses(&tabstrip, contents1, contents2, contents3);
1099 EXPECT_EQ(0, tabstrip.active_index()); 1099 EXPECT_EQ(0, tabstrip.active_index());
1100 1100
1101 tabstrip.ExecuteContextMenuCommand(2, TabStripModel::CommandCloseTab); 1101 tabstrip.ExecuteContextMenuCommand(2, TabStripModel::CommandCloseTab);
1102 EXPECT_EQ(3, tabstrip.count()); 1102 EXPECT_EQ(3, tabstrip.count());
1103 1103
1104 tabstrip.ExecuteContextMenuCommand(0, TabStripModel::CommandCloseTabsToRight); 1104 tabstrip.ExecuteContextMenuCommand(0, TabStripModel::CommandCloseTabsToRight);
1105 EXPECT_EQ(1, tabstrip.count()); 1105 EXPECT_EQ(1, tabstrip.count());
1106 EXPECT_EQ(opener_contents, tabstrip.GetSelectedTabContents()); 1106 EXPECT_EQ(opener_contents, tabstrip.GetActiveTabContents());
1107 1107
1108 TabContentsWrapper* dummy_contents = CreateTabContents(); 1108 TabContentsWrapper* dummy_contents = CreateTabContents();
1109 tabstrip.AppendTabContents(dummy_contents, false); 1109 tabstrip.AppendTabContents(dummy_contents, false);
1110 1110
1111 contents1 = CreateTabContents(); 1111 contents1 = CreateTabContents();
1112 contents2 = CreateTabContents(); 1112 contents2 = CreateTabContents();
1113 contents3 = CreateTabContents(); 1113 contents3 = CreateTabContents();
1114 InsertTabContentses(&tabstrip, contents1, contents2, contents3); 1114 InsertTabContentses(&tabstrip, contents1, contents2, contents3);
1115 EXPECT_EQ(5, tabstrip.count()); 1115 EXPECT_EQ(5, tabstrip.count());
1116 1116
1117 int dummy_index = tabstrip.count() - 1; 1117 int dummy_index = tabstrip.count() - 1;
1118 tabstrip.ActivateTabAt(dummy_index, true); 1118 tabstrip.ActivateTabAt(dummy_index, true);
1119 EXPECT_EQ(dummy_contents, tabstrip.GetSelectedTabContents()); 1119 EXPECT_EQ(dummy_contents, tabstrip.GetActiveTabContents());
1120 1120
1121 tabstrip.ExecuteContextMenuCommand(dummy_index, 1121 tabstrip.ExecuteContextMenuCommand(dummy_index,
1122 TabStripModel::CommandCloseOtherTabs); 1122 TabStripModel::CommandCloseOtherTabs);
1123 EXPECT_EQ(1, tabstrip.count()); 1123 EXPECT_EQ(1, tabstrip.count());
1124 EXPECT_EQ(dummy_contents, tabstrip.GetSelectedTabContents()); 1124 EXPECT_EQ(dummy_contents, tabstrip.GetActiveTabContents());
1125 1125
1126 tabstrip.CloseAllTabs(); 1126 tabstrip.CloseAllTabs();
1127 EXPECT_TRUE(tabstrip.empty()); 1127 EXPECT_TRUE(tabstrip.empty());
1128 } 1128 }
1129 1129
1130 // Tests GetIndicesClosedByCommand. 1130 // Tests GetIndicesClosedByCommand.
1131 TEST_F(TabStripModelTest, GetIndicesClosedByCommand) { 1131 TEST_F(TabStripModelTest, GetIndicesClosedByCommand) {
1132 TabStripDummyDelegate delegate(NULL); 1132 TabStripDummyDelegate delegate(NULL);
1133 TabStripModel tabstrip(&delegate, profile()); 1133 TabStripModel tabstrip(&delegate, profile());
1134 EXPECT_TRUE(tabstrip.empty()); 1134 EXPECT_TRUE(tabstrip.empty());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(4)); 1223 EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(4));
1224 1224
1225 // Now simulate seleting a tab in the middle of the group of tabs opened from 1225 // Now simulate seleting a tab in the middle of the group of tabs opened from
1226 // the home page and start closing them. Each TabContents in the group should 1226 // the home page and start closing them. Each TabContents in the group should
1227 // be closed, right to left. This test is constructed to start at the middle 1227 // be closed, right to left. This test is constructed to start at the middle
1228 // TabContents in the group to make sure the cursor wraps around to the first 1228 // TabContents in the group to make sure the cursor wraps around to the first
1229 // TabContents in the group before closing the opener or any other 1229 // TabContents in the group before closing the opener or any other
1230 // TabContents. 1230 // TabContents.
1231 tabstrip.ActivateTabAt(2, true); 1231 tabstrip.ActivateTabAt(2, true);
1232 tabstrip.CloseSelectedTabs(); 1232 tabstrip.CloseSelectedTabs();
1233 EXPECT_EQ(middle_click_contents3, tabstrip.GetSelectedTabContents()); 1233 EXPECT_EQ(middle_click_contents3, tabstrip.GetActiveTabContents());
1234 tabstrip.CloseSelectedTabs(); 1234 tabstrip.CloseSelectedTabs();
1235 EXPECT_EQ(middle_click_contents1, tabstrip.GetSelectedTabContents()); 1235 EXPECT_EQ(middle_click_contents1, tabstrip.GetActiveTabContents());
1236 tabstrip.CloseSelectedTabs(); 1236 tabstrip.CloseSelectedTabs();
1237 EXPECT_EQ(homepage_contents, tabstrip.GetSelectedTabContents()); 1237 EXPECT_EQ(homepage_contents, tabstrip.GetActiveTabContents());
1238 tabstrip.CloseSelectedTabs(); 1238 tabstrip.CloseSelectedTabs();
1239 EXPECT_EQ(typed_page_contents, tabstrip.GetSelectedTabContents()); 1239 EXPECT_EQ(typed_page_contents, tabstrip.GetActiveTabContents());
1240 1240
1241 EXPECT_EQ(1, tabstrip.count()); 1241 EXPECT_EQ(1, tabstrip.count());
1242 1242
1243 tabstrip.CloseAllTabs(); 1243 tabstrip.CloseAllTabs();
1244 EXPECT_TRUE(tabstrip.empty()); 1244 EXPECT_TRUE(tabstrip.empty());
1245 } 1245 }
1246 1246
1247 // Tests whether or not a TabContents created by a left click on a link that 1247 // Tests whether or not a TabContents created by a left click on a link that
1248 // opens a new tab is inserted correctly adjacent to the tab that spawned it. 1248 // opens a new tab is inserted correctly adjacent to the tab that spawned it.
1249 TEST_F(TabStripModelTest, AddTabContents_LeftClickPopup) { 1249 TEST_F(TabStripModelTest, AddTabContents_LeftClickPopup) {
(...skipping 23 matching lines...) Expand all
1273 tabstrip.AddTabContents(left_click_contents, -1, PageTransition::LINK, 1273 tabstrip.AddTabContents(left_click_contents, -1, PageTransition::LINK,
1274 TabStripModel::ADD_ACTIVE); 1274 TabStripModel::ADD_ACTIVE);
1275 1275
1276 // Verify the state meets our expectations. 1276 // Verify the state meets our expectations.
1277 EXPECT_EQ(3, tabstrip.count()); 1277 EXPECT_EQ(3, tabstrip.count());
1278 EXPECT_EQ(homepage_contents, tabstrip.GetTabContentsAt(0)); 1278 EXPECT_EQ(homepage_contents, tabstrip.GetTabContentsAt(0));
1279 EXPECT_EQ(left_click_contents, tabstrip.GetTabContentsAt(1)); 1279 EXPECT_EQ(left_click_contents, tabstrip.GetTabContentsAt(1));
1280 EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(2)); 1280 EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(2));
1281 1281
1282 // The newly created tab should be selected. 1282 // The newly created tab should be selected.
1283 EXPECT_EQ(left_click_contents, tabstrip.GetSelectedTabContents()); 1283 EXPECT_EQ(left_click_contents, tabstrip.GetActiveTabContents());
1284 1284
1285 // After closing the selected tab, the selection should move to the left, to 1285 // After closing the selected tab, the selection should move to the left, to
1286 // the opener. 1286 // the opener.
1287 tabstrip.CloseSelectedTabs(); 1287 tabstrip.CloseSelectedTabs();
1288 EXPECT_EQ(homepage_contents, tabstrip.GetSelectedTabContents()); 1288 EXPECT_EQ(homepage_contents, tabstrip.GetActiveTabContents());
1289 1289
1290 EXPECT_EQ(2, tabstrip.count()); 1290 EXPECT_EQ(2, tabstrip.count());
1291 1291
1292 tabstrip.CloseAllTabs(); 1292 tabstrip.CloseAllTabs();
1293 EXPECT_TRUE(tabstrip.empty()); 1293 EXPECT_TRUE(tabstrip.empty());
1294 } 1294 }
1295 1295
1296 // Tests whether or not new tabs that should split context (typed pages, 1296 // Tests whether or not new tabs that should split context (typed pages,
1297 // generated urls, also blank tabs) open at the end of the tabstrip instead of 1297 // generated urls, also blank tabs) open at the end of the tabstrip instead of
1298 // in the middle. 1298 // in the middle.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 middle_click_contents2, -1, PageTransition::LINK, 1384 middle_click_contents2, -1, PageTransition::LINK,
1385 TabStripModel::ADD_NONE); 1385 TabStripModel::ADD_NONE);
1386 TabContentsWrapper* middle_click_contents3 = CreateTabContents(); 1386 TabContentsWrapper* middle_click_contents3 = CreateTabContents();
1387 tabstrip.AddTabContents( 1387 tabstrip.AddTabContents(
1388 middle_click_contents3, -1, PageTransition::LINK, 1388 middle_click_contents3, -1, PageTransition::LINK,
1389 TabStripModel::ADD_NONE); 1389 TabStripModel::ADD_NONE);
1390 1390
1391 // Break out of the context by selecting a tab in a different context. 1391 // Break out of the context by selecting a tab in a different context.
1392 EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(4)); 1392 EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(4));
1393 tabstrip.SelectLastTab(); 1393 tabstrip.SelectLastTab();
1394 EXPECT_EQ(typed_page_contents, tabstrip.GetSelectedTabContents()); 1394 EXPECT_EQ(typed_page_contents, tabstrip.GetActiveTabContents());
1395 1395
1396 // Step back into the context by selecting a tab inside it. 1396 // Step back into the context by selecting a tab inside it.
1397 tabstrip.ActivateTabAt(2, true); 1397 tabstrip.ActivateTabAt(2, true);
1398 EXPECT_EQ(middle_click_contents2, tabstrip.GetSelectedTabContents()); 1398 EXPECT_EQ(middle_click_contents2, tabstrip.GetActiveTabContents());
1399 1399
1400 // Now test that closing tabs selects to the right until there are no more, 1400 // Now test that closing tabs selects to the right until there are no more,
1401 // then to the left, as if there were no context (context has been 1401 // then to the left, as if there were no context (context has been
1402 // successfully forgotten). 1402 // successfully forgotten).
1403 tabstrip.CloseSelectedTabs(); 1403 tabstrip.CloseSelectedTabs();
1404 EXPECT_EQ(middle_click_contents3, tabstrip.GetSelectedTabContents()); 1404 EXPECT_EQ(middle_click_contents3, tabstrip.GetActiveTabContents());
1405 tabstrip.CloseSelectedTabs(); 1405 tabstrip.CloseSelectedTabs();
1406 EXPECT_EQ(typed_page_contents, tabstrip.GetSelectedTabContents()); 1406 EXPECT_EQ(typed_page_contents, tabstrip.GetActiveTabContents());
1407 tabstrip.CloseSelectedTabs(); 1407 tabstrip.CloseSelectedTabs();
1408 EXPECT_EQ(middle_click_contents1, tabstrip.GetSelectedTabContents()); 1408 EXPECT_EQ(middle_click_contents1, tabstrip.GetActiveTabContents());
1409 tabstrip.CloseSelectedTabs(); 1409 tabstrip.CloseSelectedTabs();
1410 EXPECT_EQ(homepage_contents, tabstrip.GetSelectedTabContents()); 1410 EXPECT_EQ(homepage_contents, tabstrip.GetActiveTabContents());
1411 1411
1412 EXPECT_EQ(1, tabstrip.count()); 1412 EXPECT_EQ(1, tabstrip.count());
1413 1413
1414 tabstrip.CloseAllTabs(); 1414 tabstrip.CloseAllTabs();
1415 EXPECT_TRUE(tabstrip.empty()); 1415 EXPECT_TRUE(tabstrip.empty());
1416 } 1416 }
1417 1417
1418 // Added for http://b/issue?id=958960 1418 // Added for http://b/issue?id=958960
1419 TEST_F(TabStripModelTest, AppendContentsReselectionTest) { 1419 TEST_F(TabStripModelTest, AppendContentsReselectionTest) {
1420 TabContents* fake_destinations_tab = 1420 TabContents* fake_destinations_tab =
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 // Simulate middle click to open page A.A and A.B 1465 // Simulate middle click to open page A.A and A.B
1466 TabContentsWrapper* page_a_a_contents = CreateTabContents(); 1466 TabContentsWrapper* page_a_a_contents = CreateTabContents();
1467 strip.AddTabContents(page_a_a_contents, -1, PageTransition::LINK, 1467 strip.AddTabContents(page_a_a_contents, -1, PageTransition::LINK,
1468 TabStripModel::ADD_NONE); 1468 TabStripModel::ADD_NONE);
1469 TabContentsWrapper* page_a_b_contents = CreateTabContents(); 1469 TabContentsWrapper* page_a_b_contents = CreateTabContents();
1470 strip.AddTabContents(page_a_b_contents, -1, PageTransition::LINK, 1470 strip.AddTabContents(page_a_b_contents, -1, PageTransition::LINK,
1471 TabStripModel::ADD_NONE); 1471 TabStripModel::ADD_NONE);
1472 1472
1473 // Select page A.A 1473 // Select page A.A
1474 strip.ActivateTabAt(1, true); 1474 strip.ActivateTabAt(1, true);
1475 EXPECT_EQ(page_a_a_contents, strip.GetSelectedTabContents()); 1475 EXPECT_EQ(page_a_a_contents, strip.GetActiveTabContents());
1476 1476
1477 // Simulate a middle click to open page A.A.A 1477 // Simulate a middle click to open page A.A.A
1478 TabContentsWrapper* page_a_a_a_contents = CreateTabContents(); 1478 TabContentsWrapper* page_a_a_a_contents = CreateTabContents();
1479 strip.AddTabContents(page_a_a_a_contents, -1, PageTransition::LINK, 1479 strip.AddTabContents(page_a_a_a_contents, -1, PageTransition::LINK,
1480 TabStripModel::ADD_NONE); 1480 TabStripModel::ADD_NONE);
1481 1481
1482 EXPECT_EQ(page_a_a_a_contents, strip.GetTabContentsAt(2)); 1482 EXPECT_EQ(page_a_a_a_contents, strip.GetTabContentsAt(2));
1483 1483
1484 // Close page A.A 1484 // Close page A.A
1485 strip.CloseTabContentsAt(strip.active_index(), TabStripModel::CLOSE_NONE); 1485 strip.CloseTabContentsAt(strip.active_index(), TabStripModel::CLOSE_NONE);
1486 1486
1487 // Page A.A.A should be selected, NOT A.B 1487 // Page A.A.A should be selected, NOT A.B
1488 EXPECT_EQ(page_a_a_a_contents, strip.GetSelectedTabContents()); 1488 EXPECT_EQ(page_a_a_a_contents, strip.GetActiveTabContents());
1489 1489
1490 // Close page A.A.A 1490 // Close page A.A.A
1491 strip.CloseTabContentsAt(strip.active_index(), TabStripModel::CLOSE_NONE); 1491 strip.CloseTabContentsAt(strip.active_index(), TabStripModel::CLOSE_NONE);
1492 1492
1493 // Page A.B should be selected 1493 // Page A.B should be selected
1494 EXPECT_EQ(page_a_b_contents, strip.GetSelectedTabContents()); 1494 EXPECT_EQ(page_a_b_contents, strip.GetActiveTabContents());
1495 1495
1496 // Close page A.B 1496 // Close page A.B
1497 strip.CloseTabContentsAt(strip.active_index(), TabStripModel::CLOSE_NONE); 1497 strip.CloseTabContentsAt(strip.active_index(), TabStripModel::CLOSE_NONE);
1498 1498
1499 // Page A should be selected 1499 // Page A should be selected
1500 EXPECT_EQ(page_a_contents, strip.GetSelectedTabContents()); 1500 EXPECT_EQ(page_a_contents, strip.GetActiveTabContents());
1501 1501
1502 // Clean up. 1502 // Clean up.
1503 strip.CloseAllTabs(); 1503 strip.CloseAllTabs();
1504 } 1504 }
1505 1505
1506 TEST_F(TabStripModelTest, AddTabContents_NewTabAtEndOfStripInheritsGroup) { 1506 TEST_F(TabStripModelTest, AddTabContents_NewTabAtEndOfStripInheritsGroup) {
1507 TabStripDummyDelegate delegate(NULL); 1507 TabStripDummyDelegate delegate(NULL);
1508 TabStripModel strip(&delegate, profile()); 1508 TabStripModel strip(&delegate, profile());
1509 1509
1510 // Open page A 1510 // Open page A
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « chrome/browser/tabs/tab_strip_model_order_controller.cc ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698