| 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" |
| (...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 // Clean up. | 1557 // Clean up. |
| 1558 strip.CloseAllTabs(); | 1558 strip.CloseAllTabs(); |
| 1559 } | 1559 } |
| 1560 | 1560 |
| 1561 TEST_F(TabStripModelTest, AddTabContents_NewTabAtEndOfStripInheritsGroup) { | 1561 TEST_F(TabStripModelTest, AddTabContents_NewTabAtEndOfStripInheritsGroup) { |
| 1562 TabStripDummyDelegate delegate(NULL); | 1562 TabStripDummyDelegate delegate(NULL); |
| 1563 TabStripModel strip(&delegate, profile()); | 1563 TabStripModel strip(&delegate, profile()); |
| 1564 | 1564 |
| 1565 // Open page A | 1565 // Open page A |
| 1566 TabContents* page_a_contents = CreateTabContents(); | 1566 TabContents* page_a_contents = CreateTabContents(); |
| 1567 strip.AddTabContents(page_a_contents, -1, content::PAGE_TRANSITION_START_PAGE, | 1567 strip.AddTabContents(page_a_contents, -1, |
| 1568 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 1568 TabStripModel::ADD_ACTIVE); | 1569 TabStripModel::ADD_ACTIVE); |
| 1569 | 1570 |
| 1570 // Open pages B, C and D in the background from links on page A... | 1571 // Open pages B, C and D in the background from links on page A... |
| 1571 TabContents* page_b_contents = CreateTabContents(); | 1572 TabContents* page_b_contents = CreateTabContents(); |
| 1572 TabContents* page_c_contents = CreateTabContents(); | 1573 TabContents* page_c_contents = CreateTabContents(); |
| 1573 TabContents* page_d_contents = CreateTabContents(); | 1574 TabContents* page_d_contents = CreateTabContents(); |
| 1574 strip.AddTabContents(page_b_contents, -1, content::PAGE_TRANSITION_LINK, | 1575 strip.AddTabContents(page_b_contents, -1, content::PAGE_TRANSITION_LINK, |
| 1575 TabStripModel::ADD_NONE); | 1576 TabStripModel::ADD_NONE); |
| 1576 strip.AddTabContents(page_c_contents, -1, content::PAGE_TRANSITION_LINK, | 1577 strip.AddTabContents(page_c_contents, -1, content::PAGE_TRANSITION_LINK, |
| 1577 TabStripModel::ADD_NONE); | 1578 TabStripModel::ADD_NONE); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 // A test of navigations in a tab that is part of a group of opened from some | 1635 // A test of navigations in a tab that is part of a group of opened from some |
| 1635 // parent tab. If the navigations are link clicks, the group relationship of | 1636 // parent tab. If the navigations are link clicks, the group relationship of |
| 1636 // the tab to its parent are preserved. If they are of any other type, they are | 1637 // the tab to its parent are preserved. If they are of any other type, they are |
| 1637 // not preserved. | 1638 // not preserved. |
| 1638 TEST_F(TabStripModelTest, NavigationForgetsOpeners) { | 1639 TEST_F(TabStripModelTest, NavigationForgetsOpeners) { |
| 1639 TabStripDummyDelegate delegate(NULL); | 1640 TabStripDummyDelegate delegate(NULL); |
| 1640 TabStripModel strip(&delegate, profile()); | 1641 TabStripModel strip(&delegate, profile()); |
| 1641 | 1642 |
| 1642 // Open page A | 1643 // Open page A |
| 1643 TabContents* page_a_contents = CreateTabContents(); | 1644 TabContents* page_a_contents = CreateTabContents(); |
| 1644 strip.AddTabContents(page_a_contents, -1, content::PAGE_TRANSITION_START_PAGE, | 1645 strip.AddTabContents(page_a_contents, -1, |
| 1646 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 1645 TabStripModel::ADD_ACTIVE); | 1647 TabStripModel::ADD_ACTIVE); |
| 1646 | 1648 |
| 1647 // Open pages B, C and D in the background from links on page A... | 1649 // Open pages B, C and D in the background from links on page A... |
| 1648 TabContents* page_b_contents = CreateTabContents(); | 1650 TabContents* page_b_contents = CreateTabContents(); |
| 1649 TabContents* page_c_contents = CreateTabContents(); | 1651 TabContents* page_c_contents = CreateTabContents(); |
| 1650 TabContents* page_d_contents = CreateTabContents(); | 1652 TabContents* page_d_contents = CreateTabContents(); |
| 1651 strip.AddTabContents(page_b_contents, -1, content::PAGE_TRANSITION_LINK, | 1653 strip.AddTabContents(page_b_contents, -1, content::PAGE_TRANSITION_LINK, |
| 1652 TabStripModel::ADD_NONE); | 1654 TabStripModel::ADD_NONE); |
| 1653 strip.AddTabContents(page_c_contents, -1, content::PAGE_TRANSITION_LINK, | 1655 strip.AddTabContents(page_c_contents, -1, content::PAGE_TRANSITION_LINK, |
| 1654 TabStripModel::ADD_NONE); | 1656 TabStripModel::ADD_NONE); |
| 1655 strip.AddTabContents(page_d_contents, -1, content::PAGE_TRANSITION_LINK, | 1657 strip.AddTabContents(page_d_contents, -1, content::PAGE_TRANSITION_LINK, |
| 1656 TabStripModel::ADD_NONE); | 1658 TabStripModel::ADD_NONE); |
| 1657 | 1659 |
| 1658 // Open page E in a different opener group from page A. | 1660 // Open page E in a different opener group from page A. |
| 1659 TabContents* page_e_contents = CreateTabContents(); | 1661 TabContents* page_e_contents = CreateTabContents(); |
| 1660 strip.AddTabContents(page_e_contents, -1, content::PAGE_TRANSITION_START_PAGE, | 1662 strip.AddTabContents(page_e_contents, -1, |
| 1663 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 1661 TabStripModel::ADD_NONE); | 1664 TabStripModel::ADD_NONE); |
| 1662 | 1665 |
| 1663 // Tell the TabStripModel that we are navigating page D via a link click. | 1666 // Tell the TabStripModel that we are navigating page D via a link click. |
| 1664 strip.ActivateTabAt(3, true); | 1667 strip.ActivateTabAt(3, true); |
| 1665 strip.TabNavigating(page_d_contents, content::PAGE_TRANSITION_LINK); | 1668 strip.TabNavigating(page_d_contents, content::PAGE_TRANSITION_LINK); |
| 1666 | 1669 |
| 1667 // Close page D, page C should be selected. (part of same group). | 1670 // Close page D, page C should be selected. (part of same group). |
| 1668 strip.CloseTabContentsAt(3, TabStripModel::CLOSE_NONE); | 1671 strip.CloseTabContentsAt(3, TabStripModel::CLOSE_NONE); |
| 1669 EXPECT_EQ(2, strip.active_index()); | 1672 EXPECT_EQ(2, strip.active_index()); |
| 1670 | 1673 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1683 // doesn't cause the opener relationship for a New Tab opened at the end of the | 1686 // doesn't cause the opener relationship for a New Tab opened at the end of the |
| 1684 // TabStrip to be reset (Test 1 below), unless another any other tab is | 1687 // TabStrip to be reset (Test 1 below), unless another any other tab is |
| 1685 // seelcted (Test 2 below). | 1688 // seelcted (Test 2 below). |
| 1686 TEST_F(TabStripModelTest, NavigationForgettingDoesntAffectNewTab) { | 1689 TEST_F(TabStripModelTest, NavigationForgettingDoesntAffectNewTab) { |
| 1687 TabStripDummyDelegate delegate(NULL); | 1690 TabStripDummyDelegate delegate(NULL); |
| 1688 TabStripModel strip(&delegate, profile()); | 1691 TabStripModel strip(&delegate, profile()); |
| 1689 | 1692 |
| 1690 // Open a tab and several tabs from it, then select one of the tabs that was | 1693 // Open a tab and several tabs from it, then select one of the tabs that was |
| 1691 // opened. | 1694 // opened. |
| 1692 TabContents* page_a_contents = CreateTabContents(); | 1695 TabContents* page_a_contents = CreateTabContents(); |
| 1693 strip.AddTabContents(page_a_contents, -1, content::PAGE_TRANSITION_START_PAGE, | 1696 strip.AddTabContents(page_a_contents, -1, |
| 1697 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 1694 TabStripModel::ADD_ACTIVE); | 1698 TabStripModel::ADD_ACTIVE); |
| 1695 | 1699 |
| 1696 TabContents* page_b_contents = CreateTabContents(); | 1700 TabContents* page_b_contents = CreateTabContents(); |
| 1697 TabContents* page_c_contents = CreateTabContents(); | 1701 TabContents* page_c_contents = CreateTabContents(); |
| 1698 TabContents* page_d_contents = CreateTabContents(); | 1702 TabContents* page_d_contents = CreateTabContents(); |
| 1699 strip.AddTabContents(page_b_contents, -1, content::PAGE_TRANSITION_LINK, | 1703 strip.AddTabContents(page_b_contents, -1, content::PAGE_TRANSITION_LINK, |
| 1700 TabStripModel::ADD_NONE); | 1704 TabStripModel::ADD_NONE); |
| 1701 strip.AddTabContents(page_c_contents, -1, content::PAGE_TRANSITION_LINK, | 1705 strip.AddTabContents(page_c_contents, -1, content::PAGE_TRANSITION_LINK, |
| 1702 TabStripModel::ADD_NONE); | 1706 TabStripModel::ADD_NONE); |
| 1703 strip.AddTabContents(page_d_contents, -1, content::PAGE_TRANSITION_LINK, | 1707 strip.AddTabContents(page_d_contents, -1, content::PAGE_TRANSITION_LINK, |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2435 ASSERT_EQ(1, observer.GetStateCount()); | 2439 ASSERT_EQ(1, observer.GetStateCount()); |
| 2436 MockTabStripModelObserver::State s( | 2440 MockTabStripModelObserver::State s( |
| 2437 contents2, 1, MockTabStripModelObserver::SELECT); | 2441 contents2, 1, MockTabStripModelObserver::SELECT); |
| 2438 s.src_contents = contents2; | 2442 s.src_contents = contents2; |
| 2439 s.src_index = 1; | 2443 s.src_index = 1; |
| 2440 s.user_gesture = false; | 2444 s.user_gesture = false; |
| 2441 EXPECT_TRUE(observer.StateEquals(0, s)); | 2445 EXPECT_TRUE(observer.StateEquals(0, s)); |
| 2442 strip.RemoveObserver(&observer); | 2446 strip.RemoveObserver(&observer); |
| 2443 strip.CloseAllTabs(); | 2447 strip.CloseAllTabs(); |
| 2444 } | 2448 } |
| OLD | NEW |