| 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 #if defined(OS_POSIX) | 5 #if defined(OS_POSIX) |
| 6 #include <signal.h> | 6 #include <signal.h> |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 content::WindowedNotificationObserver window_observer( | 188 content::WindowedNotificationObserver window_observer( |
| 189 chrome::NOTIFICATION_BROWSER_CLOSED, | 189 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 190 content::NotificationService::AllSources()); | 190 content::NotificationService::AllSources()); |
| 191 chrome::CloseWindow(browser()); | 191 chrome::CloseWindow(browser()); |
| 192 window_observer.Wait(); | 192 window_observer.Wait(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 // If |accept| is true, simulates user clicking OK, otherwise simulates | 195 // If |accept| is true, simulates user clicking OK, otherwise simulates |
| 196 // clicking Cancel. | 196 // clicking Cancel. |
| 197 void ClickModalDialogButton(bool accept) { | 197 void ClickModalDialogButton(bool accept) { |
| 198 app_modal::AppModalDialog* dialog = ui_test_utils::WaitForAppModalDialog(); | 198 app_modal::JavaScriptAppModalDialog* dialog = |
| 199 ASSERT_TRUE(dialog->IsJavaScriptModalDialog()); | 199 ui_test_utils::WaitForAppModalDialog(); |
| 200 app_modal::JavaScriptAppModalDialog* js_dialog = | |
| 201 static_cast<app_modal::JavaScriptAppModalDialog*>(dialog); | |
| 202 if (accept) | 200 if (accept) |
| 203 js_dialog->native_dialog()->AcceptAppModalDialog(); | 201 dialog->native_dialog()->AcceptAppModalDialog(); |
| 204 else | 202 else |
| 205 js_dialog->native_dialog()->CancelAppModalDialog(); | 203 dialog->native_dialog()->CancelAppModalDialog(); |
| 206 } | 204 } |
| 207 | 205 |
| 208 void PrepareForDialog(Browser* browser) { | 206 void PrepareForDialog(Browser* browser) { |
| 209 for (int i = 0; i < browser->tab_strip_model()->count(); i++) { | 207 for (int i = 0; i < browser->tab_strip_model()->count(); i++) { |
| 210 content::PrepContentsForBeforeUnloadTest( | 208 content::PrepContentsForBeforeUnloadTest( |
| 211 browser->tab_strip_model()->GetWebContentsAt(i)); | 209 browser->tab_strip_model()->GetWebContentsAt(i)); |
| 212 } | 210 } |
| 213 } | 211 } |
| 214 }; | 212 }; |
| 215 | 213 |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 base::Bind(&UnloadResults::AddSuccess, base::Unretained(&unload_results)), | 925 base::Bind(&UnloadResults::AddSuccess, base::Unretained(&unload_results)), |
| 928 base::Bind(&UnloadResults::AddAbort, base::Unretained(&unload_results)), | 926 base::Bind(&UnloadResults::AddAbort, base::Unretained(&unload_results)), |
| 929 true); | 927 true); |
| 930 window_observer.Wait(); | 928 window_observer.Wait(); |
| 931 EXPECT_EQ(1, unload_results.get_successes()); | 929 EXPECT_EQ(1, unload_results.get_successes()); |
| 932 EXPECT_EQ(0, unload_results.get_aborts()); | 930 EXPECT_EQ(0, unload_results.get_aborts()); |
| 933 } | 931 } |
| 934 | 932 |
| 935 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs | 933 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs |
| 936 // and multiple windows. | 934 // and multiple windows. |
| OLD | NEW |