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

Side by Side Diff: chrome/browser/chromeos/oom_priority_manager_browsertest.cc

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
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/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/find_bar/find_bar_controller.h" 10 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
11 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
14 #include "content/public/browser/notification_types.h" 16 #include "content/public/browser/notification_types.h"
15 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
16 18
17 using content::OpenURLParams; 19 using content::OpenURLParams;
18 20
19 namespace { 21 namespace {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 false); 74 false);
73 browser()->OpenURL(open5); 75 browser()->OpenURL(open5);
74 load5.Wait(); 76 load5.Wait();
75 77
76 EXPECT_EQ(3, browser()->tab_count()); 78 EXPECT_EQ(3, browser()->tab_count());
77 79
78 // Discard a tab. It should kill the first tab, since it was the oldest 80 // Discard a tab. It should kill the first tab, since it was the oldest
79 // and was not selected. 81 // and was not selected.
80 EXPECT_TRUE(g_browser_process->oom_priority_manager()->DiscardTab()); 82 EXPECT_TRUE(g_browser_process->oom_priority_manager()->DiscardTab());
81 EXPECT_EQ(3, browser()->tab_count()); 83 EXPECT_EQ(3, browser()->tab_count());
82 EXPECT_TRUE(browser()->IsTabDiscarded(0)); 84 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(0));
83 EXPECT_FALSE(browser()->IsTabDiscarded(1)); 85 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(1));
84 EXPECT_FALSE(browser()->IsTabDiscarded(2)); 86 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(2));
85 87
86 // Run discard again, make sure it kills the second tab. 88 // Run discard again, make sure it kills the second tab.
87 g_browser_process->oom_priority_manager()->DiscardTab(); 89 g_browser_process->oom_priority_manager()->DiscardTab();
88 EXPECT_EQ(3, browser()->tab_count()); 90 EXPECT_EQ(3, browser()->tab_count());
89 EXPECT_TRUE(browser()->IsTabDiscarded(0)); 91 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(0));
90 EXPECT_TRUE(browser()->IsTabDiscarded(1)); 92 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(1));
91 EXPECT_FALSE(browser()->IsTabDiscarded(2)); 93 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(2));
92 94
93 // Kill the third tab 95 // Kill the third tab
94 EXPECT_TRUE(g_browser_process->oom_priority_manager()->DiscardTab()); 96 EXPECT_TRUE(g_browser_process->oom_priority_manager()->DiscardTab());
95 EXPECT_TRUE(browser()->IsTabDiscarded(0)); 97 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(0));
96 EXPECT_TRUE(browser()->IsTabDiscarded(1)); 98 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(1));
97 EXPECT_TRUE(browser()->IsTabDiscarded(2)); 99 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(2));
98 100
99 // Running when all tabs are discarded should do nothing. 101 // Running when all tabs are discarded should do nothing.
100 EXPECT_FALSE(g_browser_process->oom_priority_manager()->DiscardTab()); 102 EXPECT_FALSE(g_browser_process->oom_priority_manager()->DiscardTab());
101 103
102 // Force creation of the FindBarController. 104 // Force creation of the FindBarController.
103 browser()->GetFindBarController(); 105 browser()->GetFindBarController();
104 106
105 // Select the first tab. It should reload. 107 // Select the first tab. It should reload.
106 WindowedNotificationObserver reload1( 108 WindowedNotificationObserver reload1(
107 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 109 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
108 content::NotificationService::AllSources()); 110 content::NotificationService::AllSources());
109 chrome::SelectNumberedTab(browser(), 0); 111 chrome::SelectNumberedTab(browser(), 0);
110 reload1.Wait(); 112 reload1.Wait();
111 // Make sure the FindBarController gets the right TabContents. 113 // Make sure the FindBarController gets the right TabContents.
112 EXPECT_EQ(browser()->GetFindBarController()->tab_contents(), 114 EXPECT_EQ(browser()->GetFindBarController()->tab_contents(),
113 browser()->GetActiveTabContents()); 115 chrome::GetActiveTabContents(browser()));
114 EXPECT_EQ(0, browser()->active_index()); 116 EXPECT_EQ(0, browser()->active_index());
115 EXPECT_FALSE(browser()->IsTabDiscarded(0)); 117 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(0));
116 EXPECT_TRUE(browser()->IsTabDiscarded(1)); 118 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(1));
117 EXPECT_TRUE(browser()->IsTabDiscarded(2)); 119 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(2));
118 120
119 // Select the third tab. It should reload. 121 // Select the third tab. It should reload.
120 WindowedNotificationObserver reload2( 122 WindowedNotificationObserver reload2(
121 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 123 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
122 content::NotificationService::AllSources()); 124 content::NotificationService::AllSources());
123 chrome::SelectNumberedTab(browser(), 2); 125 chrome::SelectNumberedTab(browser(), 2);
124 reload2.Wait(); 126 reload2.Wait();
125 EXPECT_EQ(2, browser()->active_index()); 127 EXPECT_EQ(2, browser()->active_index());
126 EXPECT_FALSE(browser()->IsTabDiscarded(0)); 128 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(0));
127 EXPECT_TRUE(browser()->IsTabDiscarded(1)); 129 EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(1));
128 EXPECT_FALSE(browser()->IsTabDiscarded(2)); 130 EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(2));
129 131
130 // Navigate the third tab back twice. We used to crash here due to 132 // Navigate the third tab back twice. We used to crash here due to
131 // crbug.com/121373. 133 // crbug.com/121373.
132 EXPECT_TRUE(chrome::CanGoBack(browser())); 134 EXPECT_TRUE(chrome::CanGoBack(browser()));
133 EXPECT_FALSE(chrome::CanGoForward(browser())); 135 EXPECT_FALSE(chrome::CanGoForward(browser()));
134 WindowedNotificationObserver back1( 136 WindowedNotificationObserver back1(
135 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 137 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
136 content::NotificationService::AllSources()); 138 content::NotificationService::AllSources());
137 chrome::GoBack(browser(), CURRENT_TAB); 139 chrome::GoBack(browser(), CURRENT_TAB);
138 back1.Wait(); 140 back1.Wait();
139 EXPECT_TRUE(chrome::CanGoBack(browser())); 141 EXPECT_TRUE(chrome::CanGoBack(browser()));
140 EXPECT_TRUE(chrome::CanGoForward(browser())); 142 EXPECT_TRUE(chrome::CanGoForward(browser()));
141 WindowedNotificationObserver back2( 143 WindowedNotificationObserver back2(
142 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 144 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
143 content::NotificationService::AllSources()); 145 content::NotificationService::AllSources());
144 chrome::GoBack(browser(), CURRENT_TAB); 146 chrome::GoBack(browser(), CURRENT_TAB);
145 back2.Wait(); 147 back2.Wait();
146 EXPECT_FALSE(chrome::CanGoBack(browser())); 148 EXPECT_FALSE(chrome::CanGoBack(browser()));
147 EXPECT_TRUE(chrome::CanGoForward(browser())); 149 EXPECT_TRUE(chrome::CanGoForward(browser()));
148 } 150 }
149 151
150 } // namespace 152 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/media/media_player.cc ('k') | chrome/browser/collected_cookies_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698