| 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 "chrome/browser/tabs/tab_strip_model.h" | 5 #include "chrome/browser/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 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1740 tabstrip.AppendTabContents(contents2, true); | 1740 tabstrip.AppendTabContents(contents2, true); |
| 1741 | 1741 |
| 1742 // Turn on the fake unload listener so the tabs don't actually get shut | 1742 // Turn on the fake unload listener so the tabs don't actually get shut |
| 1743 // down when we call CloseAllTabs()---we need to be able to check that | 1743 // down when we call CloseAllTabs()---we need to be able to check that |
| 1744 // fast shutdown was attempted. | 1744 // fast shutdown was attempted. |
| 1745 delegate.set_run_unload_listener(true); | 1745 delegate.set_run_unload_listener(true); |
| 1746 tabstrip.CloseAllTabs(); | 1746 tabstrip.CloseAllTabs(); |
| 1747 // On a mock RPH this checks whether we *attempted* fast shutdown. | 1747 // On a mock RPH this checks whether we *attempted* fast shutdown. |
| 1748 // A real RPH would reject our attempt since there is an unload handler. | 1748 // A real RPH would reject our attempt since there is an unload handler. |
| 1749 EXPECT_TRUE(contents1->tab_contents()-> | 1749 EXPECT_TRUE(contents1->tab_contents()-> |
| 1750 GetRenderProcessHost()->fast_shutdown_started()); | 1750 GetRenderProcessHost()->FastShutdownStarted()); |
| 1751 EXPECT_EQ(2, tabstrip.count()); | 1751 EXPECT_EQ(2, tabstrip.count()); |
| 1752 | 1752 |
| 1753 delegate.set_run_unload_listener(false); | 1753 delegate.set_run_unload_listener(false); |
| 1754 tabstrip.CloseAllTabs(); | 1754 tabstrip.CloseAllTabs(); |
| 1755 EXPECT_TRUE(tabstrip.empty()); | 1755 EXPECT_TRUE(tabstrip.empty()); |
| 1756 } | 1756 } |
| 1757 | 1757 |
| 1758 // Make sure fast shutdown is not attempted when only some tabs that share a | 1758 // Make sure fast shutdown is not attempted when only some tabs that share a |
| 1759 // RPH are shut down. | 1759 // RPH are shut down. |
| 1760 { | 1760 { |
| 1761 TabContentsWrapper* contents1 = CreateTabContents(); | 1761 TabContentsWrapper* contents1 = CreateTabContents(); |
| 1762 TabContentsWrapper* contents2 = | 1762 TabContentsWrapper* contents2 = |
| 1763 CreateTabContentsWithSharedRPH(contents1->tab_contents()); | 1763 CreateTabContentsWithSharedRPH(contents1->tab_contents()); |
| 1764 | 1764 |
| 1765 SetID(contents1->tab_contents(), 1); | 1765 SetID(contents1->tab_contents(), 1); |
| 1766 SetID(contents2->tab_contents(), 2); | 1766 SetID(contents2->tab_contents(), 2); |
| 1767 | 1767 |
| 1768 tabstrip.AppendTabContents(contents1, true); | 1768 tabstrip.AppendTabContents(contents1, true); |
| 1769 tabstrip.AppendTabContents(contents2, true); | 1769 tabstrip.AppendTabContents(contents2, true); |
| 1770 | 1770 |
| 1771 tabstrip.CloseTabContentsAt(1, TabStripModel::CLOSE_NONE); | 1771 tabstrip.CloseTabContentsAt(1, TabStripModel::CLOSE_NONE); |
| 1772 EXPECT_FALSE(contents1->tab_contents()-> | 1772 EXPECT_FALSE(contents1->tab_contents()-> |
| 1773 GetRenderProcessHost()->fast_shutdown_started()); | 1773 GetRenderProcessHost()->FastShutdownStarted()); |
| 1774 EXPECT_EQ(1, tabstrip.count()); | 1774 EXPECT_EQ(1, tabstrip.count()); |
| 1775 | 1775 |
| 1776 tabstrip.CloseAllTabs(); | 1776 tabstrip.CloseAllTabs(); |
| 1777 EXPECT_TRUE(tabstrip.empty()); | 1777 EXPECT_TRUE(tabstrip.empty()); |
| 1778 } | 1778 } |
| 1779 } | 1779 } |
| 1780 | 1780 |
| 1781 // Tests various permutations of apps. | 1781 // Tests various permutations of apps. |
| 1782 TEST_F(TabStripModelTest, Apps) { | 1782 TEST_F(TabStripModelTest, Apps) { |
| 1783 TabStripDummyDelegate delegate(NULL); | 1783 TabStripDummyDelegate delegate(NULL); |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2375 ASSERT_EQ(1, observer.GetStateCount()); | 2375 ASSERT_EQ(1, observer.GetStateCount()); |
| 2376 MockTabStripModelObserver::State s( | 2376 MockTabStripModelObserver::State s( |
| 2377 contents2, 1, MockTabStripModelObserver::SELECT); | 2377 contents2, 1, MockTabStripModelObserver::SELECT); |
| 2378 s.src_contents = contents2; | 2378 s.src_contents = contents2; |
| 2379 s.src_index = 1; | 2379 s.src_index = 1; |
| 2380 s.user_gesture = false; | 2380 s.user_gesture = false; |
| 2381 EXPECT_TRUE(observer.StateEquals(0, s)); | 2381 EXPECT_TRUE(observer.StateEquals(0, s)); |
| 2382 strip.RemoveObserver(&observer); | 2382 strip.RemoveObserver(&observer); |
| 2383 strip.CloseAllTabs(); | 2383 strip.CloseAllTabs(); |
| 2384 } | 2384 } |
| OLD | NEW |