| 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 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/test/base/ui_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
| 13 #include "components/app_modal/app_modal_dialog.h" | |
| 14 #include "components/app_modal/app_modal_dialog_queue.h" | 13 #include "components/app_modal/app_modal_dialog_queue.h" |
| 15 #include "components/app_modal/javascript_app_modal_dialog.h" | 14 #include "components/app_modal/javascript_app_modal_dialog.h" |
| 16 #include "components/app_modal/native_app_modal_dialog.h" | 15 #include "components/app_modal/native_app_modal_dialog.h" |
| 17 #include "content/public/browser/render_frame_host.h" | 16 #include "content/public/browser/render_frame_host.h" |
| 18 #include "content/public/test/test_utils.h" | 17 #include "content/public/test/test_utils.h" |
| 19 #include "extensions/browser/extension_host.h" | 18 #include "extensions/browser/extension_host.h" |
| 20 #include "extensions/browser/process_manager.h" | 19 #include "extensions/browser/process_manager.h" |
| 21 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
| 22 | 21 |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| 25 void GetNextDialog(app_modal::NativeAppModalDialog** native_dialog) { | 24 void GetNextDialog(app_modal::NativeAppModalDialog** native_dialog) { |
| 26 DCHECK(native_dialog); | 25 DCHECK(native_dialog); |
| 27 *native_dialog = nullptr; | 26 *native_dialog = nullptr; |
| 28 app_modal::AppModalDialog* dialog = ui_test_utils::WaitForAppModalDialog(); | 27 app_modal::JavaScriptAppModalDialog* dialog = |
| 29 ASSERT_TRUE(dialog->IsJavaScriptModalDialog()); | 28 ui_test_utils::WaitForAppModalDialog(); |
| 30 app_modal::JavaScriptAppModalDialog* js_dialog = | 29 *native_dialog = dialog->native_dialog(); |
| 31 static_cast<app_modal::JavaScriptAppModalDialog*>(dialog); | |
| 32 *native_dialog = js_dialog->native_dialog(); | |
| 33 ASSERT_TRUE(*native_dialog); | 30 ASSERT_TRUE(*native_dialog); |
| 34 } | 31 } |
| 35 | 32 |
| 36 void CloseDialog() { | 33 void CloseDialog() { |
| 37 app_modal::NativeAppModalDialog* dialog = nullptr; | 34 app_modal::NativeAppModalDialog* dialog = nullptr; |
| 38 ASSERT_NO_FATAL_FAILURE(GetNextDialog(&dialog)); | 35 ASSERT_NO_FATAL_FAILURE(GetNextDialog(&dialog)); |
| 39 dialog->CloseAppModalDialog(); | 36 dialog->CloseAppModalDialog(); |
| 40 } | 37 } |
| 41 | 38 |
| 42 void AcceptDialog() { | 39 void AcceptDialog() { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 156 |
| 160 // All dialogs must be closed now. | 157 // All dialogs must be closed now. |
| 161 app_modal::AppModalDialogQueue* queue = | 158 app_modal::AppModalDialogQueue* queue = |
| 162 app_modal::AppModalDialogQueue::GetInstance(); | 159 app_modal::AppModalDialogQueue::GetInstance(); |
| 163 ASSERT_TRUE(queue); | 160 ASSERT_TRUE(queue); |
| 164 EXPECT_FALSE(queue->HasActiveDialog()); | 161 EXPECT_FALSE(queue->HasActiveDialog()); |
| 165 EXPECT_EQ(0, queue->end() - queue->begin()); | 162 EXPECT_EQ(0, queue->end() - queue->begin()); |
| 166 while (call_count < num_accepted_dialogs + num_cancelled_dialogs) | 163 while (call_count < num_accepted_dialogs + num_cancelled_dialogs) |
| 167 ASSERT_NO_FATAL_FAILURE(content::RunAllPendingInMessageLoop()); | 164 ASSERT_NO_FATAL_FAILURE(content::RunAllPendingInMessageLoop()); |
| 168 } | 165 } |
| OLD | NEW |