OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/message_box_flags.h" | 5 #include "app/message_box_flags.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "chrome/app/chrome_dll_resource.h" | 7 #include "chrome/app/chrome_dll_resource.h" |
8 #include "chrome/browser/view_ids.h" | 8 #include "chrome/browser/view_ids.h" |
9 #include "chrome/test/automation/automation_proxy.h" | 9 #include "chrome/test/automation/automation_proxy.h" |
10 #include "chrome/test/automation/browser_proxy.h" | 10 #include "chrome/test/automation/browser_proxy.h" |
11 #include "chrome/test/automation/tab_proxy.h" | 11 #include "chrome/test/automation/tab_proxy.h" |
12 #include "chrome/test/automation/window_proxy.h" | 12 #include "chrome/test/automation/window_proxy.h" |
13 #include "chrome/test/ui/ui_test.h" | 13 #include "chrome/test/ui/ui_test.h" |
14 #include "chrome/test/ui_test_utils.h" | 14 #include "chrome/test/ui_test_utils.h" |
15 #include "gfx/rect.h" | 15 #include "gfx/rect.h" |
16 #include "views/event.h" | 16 #include "views/event.h" |
17 | 17 |
18 class FastShutdown : public UITest { | 18 class FastShutdown : public UITest { |
19 }; | 19 }; |
20 | 20 |
| 21 #if defined(OS_MACOSX) |
| 22 // SimulateOSClick is broken on the Mac: http://crbug.com/45162 |
| 23 #define MAYBE_SlowTermination DISABLED_SlowTermination |
| 24 #else |
| 25 #define MAYBE_SlowTermination SlowTermination |
| 26 #endif |
| 27 |
21 // This tests for a previous error where uninstalling an onbeforeunload | 28 // This tests for a previous error where uninstalling an onbeforeunload |
22 // handler would enable fast shutdown even if an onUnload handler still | 29 // handler would enable fast shutdown even if an onUnload handler still |
23 // existed. | 30 // existed. |
24 TEST_F(FastShutdown, DISABLED_SlowTermination) { | 31 TEST_F(FastShutdown, MAYBE_SlowTermination) { |
25 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 32 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
26 ASSERT_TRUE(browser.get()); | 33 ASSERT_TRUE(browser.get()); |
27 scoped_refptr<WindowProxy> window(browser->GetWindow()); | 34 scoped_refptr<WindowProxy> window(browser->GetWindow()); |
28 ASSERT_TRUE(window.get()); | 35 ASSERT_TRUE(window.get()); |
29 | 36 |
30 // This page has an unload handler. | 37 // This page has an unload handler. |
31 const FilePath dir(FILE_PATH_LITERAL("fast_shutdown")); | 38 const FilePath dir(FILE_PATH_LITERAL("fast_shutdown")); |
32 const FilePath file(FILE_PATH_LITERAL("on_unloader.html")); | 39 const FilePath file(FILE_PATH_LITERAL("on_unloader.html")); |
33 NavigateToURL(ui_test_utils::GetTestUrl(dir, file)); | 40 NavigateToURL(ui_test_utils::GetTestUrl(dir, file)); |
34 gfx::Rect bounds; | 41 gfx::Rect bounds; |
35 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &bounds, true)); | 42 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &bounds, true)); |
36 // This click will launch a popup which has a before unload handler. | 43 // This click will launch a popup which has a before unload handler. |
37 ASSERT_TRUE(window->SimulateOSClick(bounds.CenterPoint(), | 44 ASSERT_TRUE(window->SimulateOSClick(bounds.CenterPoint(), |
38 views::Event::EF_LEFT_BUTTON_DOWN)); | 45 views::Event::EF_LEFT_BUTTON_DOWN)); |
39 ASSERT_TRUE(browser->WaitForTabCountToBecome(2, action_max_timeout_ms())); | 46 ASSERT_TRUE(browser->WaitForTabCountToBecome(2, action_max_timeout_ms())); |
40 // Close the tab, removing the one and only before unload handler. | 47 // Close the tab, removing the one and only before unload handler. |
41 scoped_refptr<TabProxy> tab(browser->GetTab(1)); | 48 scoped_refptr<TabProxy> tab(browser->GetTab(1)); |
42 ASSERT_TRUE(tab->Close(true)); | 49 ASSERT_TRUE(tab->Close(true)); |
43 | 50 |
44 // Close the browser. We should launch the unload handler, which is an | 51 // Close the browser. We should launch the unload handler, which is an |
45 // alert(). | 52 // alert(). |
46 ASSERT_TRUE(browser->ApplyAccelerator(IDC_CLOSE_WINDOW)); | 53 ASSERT_TRUE(browser->ApplyAccelerator(IDC_CLOSE_WINDOW)); |
47 ASSERT_TRUE(automation()->WaitForAppModalDialog()); | 54 ASSERT_TRUE(automation()->WaitForAppModalDialog()); |
48 ASSERT_TRUE(automation()->ClickAppModalDialogButton( | 55 ASSERT_TRUE(automation()->ClickAppModalDialogButton( |
49 MessageBoxFlags::DIALOGBUTTON_OK)); | 56 MessageBoxFlags::DIALOGBUTTON_OK)); |
50 } | 57 } |
OLD | NEW |