Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/views/extensions/extension_install_dialog_view.h" | 5 #include "chrome/browser/ui/views/extensions/extension_install_dialog_view.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/extensions/extension_browsertest.h" | 12 #include "chrome/browser/extensions/extension_browsertest.h" |
| 12 #include "chrome/browser/extensions/extension_icon_manager.h" | 13 #include "chrome/browser/extensions/extension_icon_manager.h" |
| 13 #include "chrome/browser/extensions/extension_install_prompt.h" | 14 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 14 #include "chrome/browser/extensions/extension_install_prompt_test_helper.h" | 15 #include "chrome/browser/extensions/extension_install_prompt_test_helper.h" |
| 15 #include "chrome/browser/platform_util.h" | 16 #include "chrome/browser/platform_util.h" |
| 16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 19 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h" | 20 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 | 165 |
| 165 views::Widget* modal_dialog = views::DialogDelegate::CreateDialogWidget( | 166 views::Widget* modal_dialog = views::DialogDelegate::CreateDialogWidget( |
| 166 dialog.release(), nullptr, | 167 dialog.release(), nullptr, |
| 167 platform_util::GetViewForWindow( | 168 platform_util::GetViewForWindow( |
| 168 browser()->window()->GetNativeWindow())); | 169 browser()->window()->GetNativeWindow())); |
| 169 modal_dialog->Show(); | 170 modal_dialog->Show(); |
| 170 | 171 |
| 171 return delegate_view; | 172 return delegate_view; |
| 172 } | 173 } |
| 173 | 174 |
| 175 base::OneShotTimer timer; | |
|
Devlin
2017/03/23 01:25:30
needed?
Ackerman
2017/03/31 22:03:22
Nope, removed.
| |
| 176 | |
| 174 private: | 177 private: |
| 175 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogViewTest); | 178 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogViewTest); |
| 176 }; | 179 }; |
| 177 | 180 |
| 178 // Verifies that the delegate is notified when the user selects to accept or | 181 // Verifies that the delegate is notified when the user selects to accept or |
| 179 // cancel the install. | 182 // cancel the install. |
| 180 IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewTest, NotifyDelegate) { | 183 IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewTest, NotifyDelegate) { |
| 181 { | 184 { |
| 182 // User presses install. | 185 // User presses install. |
| 183 ExtensionInstallPromptTestHelper helper; | 186 ExtensionInstallPromptTestHelper helper; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 195 { | 198 { |
| 196 // Dialog is closed without the user explicitly choosing to proceed or | 199 // Dialog is closed without the user explicitly choosing to proceed or |
| 197 // cancel. | 200 // cancel. |
| 198 ExtensionInstallPromptTestHelper helper; | 201 ExtensionInstallPromptTestHelper helper; |
| 199 views::DialogDelegateView* delegate_view = CreateAndShowPrompt(&helper); | 202 views::DialogDelegateView* delegate_view = CreateAndShowPrompt(&helper); |
| 200 delegate_view->GetWidget()->Close(); | 203 delegate_view->GetWidget()->Close(); |
| 201 // TODO(devlin): Should this be ABORTED? | 204 // TODO(devlin): Should this be ABORTED? |
| 202 EXPECT_EQ(ExtensionInstallPrompt::Result::USER_CANCELED, helper.result()); | 205 EXPECT_EQ(ExtensionInstallPrompt::Result::USER_CANCELED, helper.result()); |
| 203 } | 206 } |
| 204 } | 207 } |
| 208 | |
| 209 // Verifies that the "Add extension" button is disabled initally, but enabled | |
| 210 // after a short time delay. | |
| 211 IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewTest, DelayInstalls) { | |
| 212 ExtensionInstallDialogView::SetInstallDelayForTesting(0); | |
| 213 ExtensionInstallPromptTestHelper helper; | |
| 214 views::DialogDelegateView* delegate_view = CreateAndShowPrompt(&helper); | |
| 215 | |
| 216 // Check initial button states. | |
| 217 ASSERT_FALSE(delegate_view->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | |
|
Devlin
2017/03/23 01:25:30
nit: we can make these EXPECTs instead of ASSERTs
Ackerman
2017/03/31 22:03:22
Done.
| |
| 218 ASSERT_TRUE(delegate_view->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | |
| 219 | |
| 220 // Check OK button state after timeout to verify that it is enabled. | |
| 221 base::RunLoop().RunUntilIdle(); | |
| 222 ASSERT_TRUE(delegate_view->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | |
| 223 delegate_view->Close(); | |
| 224 } | |
| OLD | NEW |