| 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/browser_process.h" | 5 #include "chrome/browser/browser_process.h" |
| 6 #include "chrome/browser/chromeos/oom_priority_manager.h" | 6 #include "chrome/browser/chromeos/oom_priority_manager.h" |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_commands.h" | 8 #include "chrome/browser/ui/browser_commands.h" |
| 9 #include "chrome/browser/ui/browser_tabstrip.h" | 9 #include "chrome/browser/ui/browser_tabstrip.h" |
| 10 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 10 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(1)); | 85 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(1)); |
| 86 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(2)); | 86 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(2)); |
| 87 | 87 |
| 88 // Run discard again, make sure it kills the second tab. | 88 // Run discard again, make sure it kills the second tab. |
| 89 g_browser_process->oom_priority_manager()->DiscardTab(); | 89 g_browser_process->oom_priority_manager()->DiscardTab(); |
| 90 EXPECT_EQ(3, browser()->tab_count()); | 90 EXPECT_EQ(3, browser()->tab_count()); |
| 91 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(0)); | 91 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(0)); |
| 92 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(1)); | 92 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(1)); |
| 93 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(2)); | 93 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(2)); |
| 94 | 94 |
| 95 // Kill the third tab | 95 // Kill the third tab. This tab is not marked becuase it will be reloaded. |
| 96 EXPECT_TRUE(g_browser_process->oom_priority_manager()->DiscardTab()); | 96 EXPECT_TRUE(g_browser_process->oom_priority_manager()->DiscardTab()); |
| 97 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(0)); | 97 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(0)); |
| 98 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(1)); | 98 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(1)); |
| 99 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(2)); | 99 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(2)); |
| 100 EXPECT_EQ(2, browser()->active_index()); |
| 100 | 101 |
| 101 // Running when all tabs are discarded should do nothing. | 102 // Kill the third tab again, make sure last tab can be killed and be reloaded |
| 102 EXPECT_FALSE(g_browser_process->oom_priority_manager()->DiscardTab()); | 103 // again. |
| 104 EXPECT_TRUE(g_browser_process->oom_priority_manager()->DiscardTab()); |
| 105 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(2)); |
| 106 EXPECT_EQ(2, browser()->active_index()); |
| 103 | 107 |
| 104 // Force creation of the FindBarController. | 108 // Force creation of the FindBarController. |
| 105 browser()->GetFindBarController(); | 109 browser()->GetFindBarController(); |
| 106 | 110 |
| 107 // Select the first tab. It should reload. | 111 // Select the first tab. It should reload. |
| 108 WindowedNotificationObserver reload1( | 112 WindowedNotificationObserver reload1( |
| 109 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 113 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 110 content::NotificationService::AllSources()); | 114 content::NotificationService::AllSources()); |
| 111 chrome::SelectNumberedTab(browser(), 0); | 115 chrome::SelectNumberedTab(browser(), 0); |
| 112 reload1.Wait(); | 116 reload1.Wait(); |
| 113 // Make sure the FindBarController gets the right TabContents. | 117 // Make sure the FindBarController gets the right TabContents. |
| 114 EXPECT_EQ(browser()->GetFindBarController()->tab_contents(), | 118 EXPECT_EQ(browser()->GetFindBarController()->tab_contents(), |
| 115 chrome::GetActiveTabContents(browser())); | 119 chrome::GetActiveTabContents(browser())); |
| 116 EXPECT_EQ(0, browser()->active_index()); | 120 EXPECT_EQ(0, browser()->active_index()); |
| 117 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(0)); | 121 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(0)); |
| 118 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(1)); | 122 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(1)); |
| 119 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(2)); | 123 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(2)); |
| 120 | 124 |
| 121 // Select the third tab. It should reload. | 125 // Select the third tab. It should reload. |
| 122 WindowedNotificationObserver reload2( | 126 WindowedNotificationObserver reload2( |
| 123 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 127 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 124 content::NotificationService::AllSources()); | 128 content::NotificationService::AllSources()); |
| 125 chrome::SelectNumberedTab(browser(), 2); | 129 chrome::SelectNumberedTab(browser(), 2); |
| 126 reload2.Wait(); | 130 reload2.Wait(); |
| 127 EXPECT_EQ(2, browser()->active_index()); | 131 EXPECT_EQ(2, browser()->active_index()); |
| 128 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(0)); | 132 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(0)); |
| 129 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(1)); | 133 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(1)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 143 WindowedNotificationObserver back2( | 147 WindowedNotificationObserver back2( |
| 144 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 148 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 145 content::NotificationService::AllSources()); | 149 content::NotificationService::AllSources()); |
| 146 chrome::GoBack(browser(), CURRENT_TAB); | 150 chrome::GoBack(browser(), CURRENT_TAB); |
| 147 back2.Wait(); | 151 back2.Wait(); |
| 148 EXPECT_FALSE(chrome::CanGoBack(browser())); | 152 EXPECT_FALSE(chrome::CanGoBack(browser())); |
| 149 EXPECT_TRUE(chrome::CanGoForward(browser())); | 153 EXPECT_TRUE(chrome::CanGoForward(browser())); |
| 150 } | 154 } |
| 151 | 155 |
| 152 } // namespace | 156 } // namespace |
| OLD | NEW |