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_util.h" | 6 #include "base/file_util.h" |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 #include "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 path_prefix.Append(FILE_PATH_LITERAL("bot2.html"))); | 31 path_prefix.Append(FILE_PATH_LITERAL("bot2.html"))); |
32 url3 = net::FilePathToFileURL( | 32 url3 = net::FilePathToFileURL( |
33 path_prefix.Append(FILE_PATH_LITERAL("bot3.html"))); | 33 path_prefix.Append(FILE_PATH_LITERAL("bot3.html"))); |
34 } | 34 } |
35 | 35 |
36 virtual void QuitBrowserAndRestore() { | 36 virtual void QuitBrowserAndRestore() { |
37 UITest::TearDown(); | 37 UITest::TearDown(); |
38 | 38 |
39 clear_profile_ = false; | 39 clear_profile_ = false; |
40 | 40 |
41 CommandLine::AppendSwitch(&launch_arguments_, | 41 launch_arguments_.AppendSwitch(switches::kRestoreLastSession); |
42 switches::kRestoreLastSession); | |
43 UITest::SetUp(); | 42 UITest::SetUp(); |
44 } | 43 } |
45 | 44 |
46 void CloseWindow(int window_index, int initial_count) { | 45 void CloseWindow(int window_index, int initial_count) { |
47 scoped_ptr<BrowserProxy> browser_proxy( | 46 scoped_ptr<BrowserProxy> browser_proxy( |
48 automation()->GetBrowserWindow(window_index)); | 47 automation()->GetBrowserWindow(window_index)); |
49 ASSERT_TRUE(browser_proxy.get()); | 48 ASSERT_TRUE(browser_proxy.get()); |
50 ASSERT_TRUE(browser_proxy->ApplyAccelerator(IDC_CLOSE_WINDOW)); | 49 ASSERT_TRUE(browser_proxy->ApplyAccelerator(IDC_CLOSE_WINDOW)); |
51 browser_proxy.reset(); | 50 browser_proxy.reset(); |
52 int window_count; | 51 int window_count; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 275 |
277 // Close the first window. | 276 // Close the first window. |
278 CloseWindow(0, 2); | 277 CloseWindow(0, 2); |
279 browser_proxy.reset(); | 278 browser_proxy.reset(); |
280 | 279 |
281 // Launch the browser again. Note, this doesn't spawn a new process, instead | 280 // Launch the browser again. Note, this doesn't spawn a new process, instead |
282 // it attaches to the current process. | 281 // it attaches to the current process. |
283 include_testing_id_ = false; | 282 include_testing_id_ = false; |
284 use_existing_browser_ = true; | 283 use_existing_browser_ = true; |
285 clear_profile_ = false; | 284 clear_profile_ = false; |
286 CommandLine::AppendSwitch(&launch_arguments_, switches::kRestoreLastSession); | 285 launch_arguments_.AppendSwitch(switches::kRestoreLastSession); |
287 LaunchBrowser(launch_arguments_, false); | 286 LaunchBrowser(launch_arguments_, false); |
288 | 287 |
289 // A new window should appear; | 288 // A new window should appear; |
290 ASSERT_TRUE(automation()->WaitForWindowCountToChange(1, &window_count, | 289 ASSERT_TRUE(automation()->WaitForWindowCountToChange(1, &window_count, |
291 action_timeout_ms()) && | 290 action_timeout_ms()) && |
292 window_count == 2); | 291 window_count == 2); |
293 | 292 |
294 // And it shouldn't have url1 in it. | 293 // And it shouldn't have url1 in it. |
295 browser_proxy.reset(automation()->GetBrowserWindow(1)); | 294 browser_proxy.reset(automation()->GetBrowserWindow(1)); |
296 ASSERT_TRUE(browser_proxy.get()); | 295 ASSERT_TRUE(browser_proxy.get()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 // Launches an app window, closes tabbed browser, launches and makes sure | 337 // Launches an app window, closes tabbed browser, launches and makes sure |
339 // we restore the tabbed browser url. | 338 // we restore the tabbed browser url. |
340 TEST_F(SessionRestoreUITest, | 339 TEST_F(SessionRestoreUITest, |
341 DISABLED_RestoreAfterClosingTabbedBrowserWithAppAndLaunching) { | 340 DISABLED_RestoreAfterClosingTabbedBrowserWithAppAndLaunching) { |
342 NavigateToURL(url1); | 341 NavigateToURL(url1); |
343 | 342 |
344 // Launch an app. | 343 // Launch an app. |
345 include_testing_id_ = false; | 344 include_testing_id_ = false; |
346 use_existing_browser_ = true; | 345 use_existing_browser_ = true; |
347 clear_profile_ = false; | 346 clear_profile_ = false; |
348 std::wstring app_launch_arguments = launch_arguments_; | 347 CommandLine app_launch_arguments = launch_arguments_; |
349 CommandLine::AppendSwitchWithValue( | 348 app_launch_arguments.AppendSwitchWithValue(switches::kApp, |
350 &app_launch_arguments, switches::kApp, UTF8ToWide(url2.spec())); | 349 UTF8ToWide(url2.spec())); |
351 LaunchBrowser(app_launch_arguments, false); | 350 LaunchBrowser(app_launch_arguments, false); |
352 int window_count; | 351 int window_count; |
353 ASSERT_TRUE(automation()->WaitForWindowCountToChange(1, &window_count, | 352 ASSERT_TRUE(automation()->WaitForWindowCountToChange(1, &window_count, |
354 action_timeout_ms())); | 353 action_timeout_ms())); |
355 ASSERT_EQ(2, window_count); | 354 ASSERT_EQ(2, window_count); |
356 | 355 |
357 // Close the first window. | 356 // Close the first window. |
358 CloseWindow(0, 2); | 357 CloseWindow(0, 2); |
359 | 358 |
360 // Restore it, which should bring back the first window with url1. | 359 // Restore it, which should bring back the first window with url1. |
361 std::wstring restore_launch_arguments = launch_arguments_; | 360 CommandLine restore_launch_arguments = launch_arguments_; |
362 CommandLine::AppendSwitch(&restore_launch_arguments, | 361 restore_launch_arguments.AppendSwitch(switches::kRestoreLastSession); |
363 switches::kRestoreLastSession); | |
364 LaunchBrowser(restore_launch_arguments, false); | 362 LaunchBrowser(restore_launch_arguments, false); |
365 ASSERT_TRUE(automation()->WaitForWindowCountToChange(1, &window_count, | 363 ASSERT_TRUE(automation()->WaitForWindowCountToChange(1, &window_count, |
366 action_timeout_ms())); | 364 action_timeout_ms())); |
367 ASSERT_EQ(2, window_count); | 365 ASSERT_EQ(2, window_count); |
368 GURL url; | 366 GURL url; |
369 AssertWindowHasOneTab(1, &url); | 367 AssertWindowHasOneTab(1, &url); |
370 ASSERT_EQ(url1, url); | 368 ASSERT_EQ(url1, url); |
371 } | 369 } |
372 | 370 |
373 // TODO(sky): bug 1200852, this test is flakey, so I'm disabling. | 371 // TODO(sky): bug 1200852, this test is flakey, so I'm disabling. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 scoped_ptr<TabProxy> tab_proxy(browser_proxy->GetTab(restored_tab_count - 2)); | 422 scoped_ptr<TabProxy> tab_proxy(browser_proxy->GetTab(restored_tab_count - 2)); |
425 ASSERT_TRUE(tab_proxy.get() != NULL); | 423 ASSERT_TRUE(tab_proxy.get() != NULL); |
426 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); | 424 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); |
427 tab_proxy.reset(browser_proxy->GetTab(restored_tab_count - 1)); | 425 tab_proxy.reset(browser_proxy->GetTab(restored_tab_count - 1)); |
428 ASSERT_TRUE(tab_proxy.get() != NULL); | 426 ASSERT_TRUE(tab_proxy.get() != NULL); |
429 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); | 427 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); |
430 | 428 |
431 ASSERT_EQ(expected_process_count, GetBrowserProcessCount()); | 429 ASSERT_EQ(expected_process_count, GetBrowserProcessCount()); |
432 } | 430 } |
433 | 431 |
OLD | NEW |