OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/app/chrome_dll_resource.h" | 9 #include "chrome/app/chrome_dll_resource.h" |
10 #include "chrome/browser/defaults.h" | |
11 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
12 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/test/automation/tab_proxy.h" | 12 #include "chrome/test/automation/tab_proxy.h" |
14 #include "chrome/test/automation/browser_proxy.h" | 13 #include "chrome/test/automation/browser_proxy.h" |
15 #include "chrome/test/automation/window_proxy.h" | 14 #include "chrome/test/automation/window_proxy.h" |
16 #include "chrome/test/ui/ui_test.h" | 15 #include "chrome/test/ui/ui_test.h" |
17 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
18 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
19 #include "net/url_request/url_request_unittest.h" | 18 #include "net/url_request/url_request_unittest.h" |
20 | 19 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 246 |
248 QuitBrowserAndRestore(1); | 247 QuitBrowserAndRestore(1); |
249 browser_proxy = NULL; | 248 browser_proxy = NULL; |
250 tab_proxy = NULL; | 249 tab_proxy = NULL; |
251 | 250 |
252 AssertOneWindowWithOneTab(); | 251 AssertOneWindowWithOneTab(); |
253 | 252 |
254 ASSERT_TRUE(GetActiveTabURL() == url1_); | 253 ASSERT_TRUE(GetActiveTabURL() == url1_); |
255 } | 254 } |
256 | 255 |
257 // Creates a tabbed browser and popup and makes sure we restore both. | |
258 TEST_F(SessionRestoreUITest, NormalAndPopup) { | |
259 if (!browser_defaults::kRestorePopups) | |
260 return; // Test only applicable if restoring popups. | |
261 | |
262 NavigateToURL(url1_); | |
263 | |
264 // Make sure we have one window. | |
265 int window_count; | |
266 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | |
267 ASSERT_EQ(1, window_count); | |
268 | |
269 // Open a popup. | |
270 ASSERT_TRUE(automation()->OpenNewBrowserWindow(BrowserProxy::TYPE_POPUP, | |
271 true)); | |
272 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | |
273 ASSERT_EQ(2, window_count); | |
274 | |
275 // Restart and make sure we have only one window with one tab and the url | |
276 // is url1_. | |
277 QuitBrowserAndRestore(1); | |
278 | |
279 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | |
280 ASSERT_EQ(2, window_count); | |
281 | |
282 scoped_refptr<BrowserProxy> browser_proxy1( | |
283 automation()->GetBrowserWindow(0)); | |
284 ASSERT_TRUE(browser_proxy1.get()); | |
285 | |
286 scoped_refptr<BrowserProxy> browser_proxy2( | |
287 automation()->GetBrowserWindow(1)); | |
288 ASSERT_TRUE(browser_proxy2.get()); | |
289 | |
290 BrowserProxy::Type type1, type2; | |
291 ASSERT_TRUE(browser_proxy1->GetType(&type1)); | |
292 ASSERT_TRUE(browser_proxy2->GetType(&type2)); | |
293 | |
294 // The order of whether the normal window or popup is first depends upon | |
295 // activation order, which is not necessarily consistant across runs. | |
296 if (type1 == BrowserProxy::TYPE_NORMAL) { | |
297 EXPECT_EQ(type2, BrowserProxy::TYPE_POPUP); | |
298 } else { | |
299 EXPECT_EQ(type1, BrowserProxy::TYPE_POPUP); | |
300 EXPECT_EQ(type2, BrowserProxy::TYPE_NORMAL); | |
301 } | |
302 } | |
303 | |
304 | |
305 #if defined(OS_WIN) | 256 #if defined(OS_WIN) |
306 // Creates a browser, goes incognito, closes browser, launches and make sure | 257 // Creates a browser, goes incognito, closes browser, launches and make sure |
307 // we don't restore. | 258 // we don't restore. |
308 TEST_F(SessionRestoreUITest, DontRestoreWhileIncognito) { | 259 TEST_F(SessionRestoreUITest, DontRestoreWhileIncognito) { |
309 NavigateToURL(url1_); | 260 NavigateToURL(url1_); |
310 | 261 |
311 // Make sure we have one window. | 262 // Make sure we have one window. |
312 int initial_window_count; | 263 int initial_window_count; |
313 ASSERT_TRUE(automation()->GetBrowserWindowCount(&initial_window_count)); | 264 ASSERT_TRUE(automation()->GetBrowserWindowCount(&initial_window_count)); |
314 ASSERT_EQ(1, initial_window_count); | 265 ASSERT_EQ(1, initial_window_count); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 // Creates two windows, closes one, restores, make sure only one window open. | 301 // Creates two windows, closes one, restores, make sure only one window open. |
351 TEST_F(SessionRestoreUITest, TwoWindowsCloseOneRestoreOnlyOne) { | 302 TEST_F(SessionRestoreUITest, TwoWindowsCloseOneRestoreOnlyOne) { |
352 NavigateToURL(url1_); | 303 NavigateToURL(url1_); |
353 | 304 |
354 // Make sure we have one window. | 305 // Make sure we have one window. |
355 int window_count; | 306 int window_count; |
356 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 307 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
357 ASSERT_EQ(1, window_count); | 308 ASSERT_EQ(1, window_count); |
358 | 309 |
359 // Open a second window. | 310 // Open a second window. |
360 ASSERT_TRUE(automation()->OpenNewBrowserWindow(BrowserProxy::TYPE_NORMAL, | 311 ASSERT_TRUE(automation()->OpenNewBrowserWindow(true)); |
361 true)); | |
362 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 312 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
363 ASSERT_EQ(2, window_count); | 313 ASSERT_EQ(2, window_count); |
364 | 314 |
365 // Close it. | 315 // Close it. |
366 CloseWindow(1, 2); | 316 CloseWindow(1, 2); |
367 | 317 |
368 // Restart and make sure we have only one window with one tab and the url | 318 // Restart and make sure we have only one window with one tab and the url |
369 // is url1_. | 319 // is url1_. |
370 QuitBrowserAndRestore(1); | 320 QuitBrowserAndRestore(1); |
371 | 321 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); | 413 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); |
464 tab_proxy = browser_proxy->GetTab(tab_count - 1); | 414 tab_proxy = browser_proxy->GetTab(tab_count - 1); |
465 ASSERT_TRUE(tab_proxy.get() != NULL); | 415 ASSERT_TRUE(tab_proxy.get() != NULL); |
466 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); | 416 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); |
467 | 417 |
468 ASSERT_EQ(expected_process_count, GetBrowserProcessCount()); | 418 ASSERT_EQ(expected_process_count, GetBrowserProcessCount()); |
469 } | 419 } |
470 #endif | 420 #endif |
471 | 421 |
472 } // namespace | 422 } // namespace |
OLD | NEW |