| 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 "chrome/browser/chromeos/extensions/echo_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/echo_private_api.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "chrome/browser/chromeos/settings/cros_settings.h" | 10 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 11 #include "chrome/browser/chromeos/ui/echo_dialog_view.h" | 11 #include "chrome/browser/chromeos/ui/echo_dialog_view.h" |
| 12 #include "chrome/browser/extensions/extension_apitest.h" | 12 #include "chrome/browser/extensions/extension_apitest.h" |
| 13 #include "chrome/browser/extensions/extension_function_test_utils.h" | 13 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 14 #include "chromeos/chromeos_switches.h" | 14 #include "chromeos/chromeos_switches.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace utils = extension_function_test_utils; | 17 namespace utils = extension_function_test_utils; |
| 18 | 18 |
| 19 namespace chromeos { | 19 namespace chromeos { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 DialogTestAction dialog_action = dialog_action_; | 74 DialogTestAction dialog_action = dialog_action_; |
| 75 if (dialog_action == DIALOG_TEST_ACTION_ACCEPT && | 75 if (dialog_action == DIALOG_TEST_ACTION_ACCEPT && |
| 76 expected_dialog_buttons_ != dialog->GetDialogButtons()) { | 76 expected_dialog_buttons_ != dialog->GetDialogButtons()) { |
| 77 dialog_action = DIALOG_TEST_ACTION_CANCEL; | 77 dialog_action = DIALOG_TEST_ACTION_CANCEL; |
| 78 } | 78 } |
| 79 | 79 |
| 80 // Perform test action on the dialog. | 80 // Perform test action on the dialog. |
| 81 // The dialog should stay around until AcceptWindow or CancelWindow is | 81 // The dialog should stay around until AcceptWindow or CancelWindow is |
| 82 // called, so base::Unretained is safe. | 82 // called, so base::Unretained is safe. |
| 83 if (dialog_action == DIALOG_TEST_ACTION_ACCEPT) { | 83 if (dialog_action == DIALOG_TEST_ACTION_ACCEPT) { |
| 84 base::MessageLoopProxy::current()->PostTask( | 84 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 85 FROM_HERE, | 85 FROM_HERE, |
| 86 base::Bind(base::IgnoreResult(&chromeos::EchoDialogView::Accept), | 86 base::Bind(base::IgnoreResult(&chromeos::EchoDialogView::Accept), |
| 87 base::Unretained(dialog))); | 87 base::Unretained(dialog))); |
| 88 } else if (dialog_action == DIALOG_TEST_ACTION_CANCEL) { | 88 } else if (dialog_action == DIALOG_TEST_ACTION_CANCEL) { |
| 89 base::MessageLoopProxy::current()->PostTask( | 89 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 90 FROM_HERE, | 90 FROM_HERE, |
| 91 base::Bind(base::IgnoreResult(&chromeos::EchoDialogView::Cancel), | 91 base::Bind(base::IgnoreResult(&chromeos::EchoDialogView::Cancel), |
| 92 base::Unretained(dialog))); | 92 base::Unretained(dialog))); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 int dialog_invocation_count() const { | 96 int dialog_invocation_count() const { |
| 97 return dialog_invocation_count_; | 97 return dialog_invocation_count_; |
| 98 } | 98 } |
| 99 | 99 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 expected_dialog_buttons_ = ui::DIALOG_BUTTON_CANCEL; | 173 expected_dialog_buttons_ = ui::DIALOG_BUTTON_CANCEL; |
| 174 dialog_action_ = DIALOG_TEST_ACTION_CANCEL; | 174 dialog_action_ = DIALOG_TEST_ACTION_CANCEL; |
| 175 | 175 |
| 176 RunDefaultGetUserFunctionAndExpectResultEquals(false); | 176 RunDefaultGetUserFunctionAndExpectResultEquals(false); |
| 177 | 177 |
| 178 EXPECT_EQ(1, dialog_invocation_count()); | 178 EXPECT_EQ(1, dialog_invocation_count()); |
| 179 } | 179 } |
| 180 | 180 |
| 181 } // namespace chromeos | 181 } // namespace chromeos |
| OLD | NEW |