Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: chrome/browser/ui/views/extensions/extension_install_dialog_view_browsertest.cc

Issue 1730893002: Revert of Remove DialogDelegate::OnClosed() which is redundant with (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/extensions/extension_browsertest.h" 11 #include "chrome/browser/extensions/extension_browsertest.h"
12 #include "chrome/browser/extensions/extension_icon_manager.h" 12 #include "chrome/browser/extensions/extension_icon_manager.h"
13 #include "chrome/browser/extensions/extension_install_prompt.h" 13 #include "chrome/browser/extensions/extension_install_prompt.h"
14 #include "chrome/browser/extensions/extension_install_prompt_test_helper.h" 14 #include "chrome/browser/extensions/extension_install_prompt_test_helper.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h" 17 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h"
19 #include "chrome/common/extensions/extension_test_util.h" 18 #include "chrome/common/extensions/extension_test_util.h"
20 #include "components/constrained_window/constrained_window_views.h" 19 #include "components/constrained_window/constrained_window_views.h"
21 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
22 #include "content/public/test/test_utils.h" 21 #include "content/public/test/test_utils.h"
23 #include "extensions/common/extension.h" 22 #include "extensions/common/extension.h"
24 #include "extensions/common/permissions/permission_message_provider.h" 23 #include "extensions/common/permissions/permission_message_provider.h"
25 #include "extensions/common/permissions/permissions_data.h" 24 #include "extensions/common/permissions/permissions_data.h"
26 #include "extensions/common/test_util.h" 25 #include "extensions/common/test_util.h"
27 #include "ui/views/controls/scroll_view.h" 26 #include "ui/views/controls/scroll_view.h"
28 #include "ui/views/view.h" 27 #include "ui/views/view.h"
29 #include "ui/views/widget/widget.h" 28 #include "ui/views/widget/widget.h"
30 #include "ui/views/window/dialog_client_view.h"
31 29
32 using extensions::PermissionIDSet; 30 using extensions::PermissionIDSet;
33 using extensions::PermissionMessage; 31 using extensions::PermissionMessage;
34 using extensions::PermissionMessages; 32 using extensions::PermissionMessages;
35 33
36 class ExtensionInstallDialogViewTestBase : public ExtensionBrowserTest { 34 class ExtensionInstallDialogViewTestBase : public ExtensionBrowserTest {
37 protected: 35 protected:
38 explicit ExtensionInstallDialogViewTestBase( 36 explicit ExtensionInstallDialogViewTestBase(
39 ExtensionInstallPrompt::PromptType prompt_type); 37 ExtensionInstallPrompt::PromptType prompt_type);
40 ~ExtensionInstallDialogViewTestBase() override {} 38 ~ExtensionInstallDialogViewTestBase() override {}
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 145 }
148 146
149 class ExtensionInstallDialogViewTest 147 class ExtensionInstallDialogViewTest
150 : public ExtensionInstallDialogViewTestBase { 148 : public ExtensionInstallDialogViewTestBase {
151 protected: 149 protected:
152 ExtensionInstallDialogViewTest() 150 ExtensionInstallDialogViewTest()
153 : ExtensionInstallDialogViewTestBase( 151 : ExtensionInstallDialogViewTestBase(
154 ExtensionInstallPrompt::INSTALL_PROMPT) {} 152 ExtensionInstallPrompt::INSTALL_PROMPT) {}
155 ~ExtensionInstallDialogViewTest() override {} 153 ~ExtensionInstallDialogViewTest() override {}
156 154
157 views::DialogDelegateView* CreateAndShowPrompt(
158 ExtensionInstallPromptTestHelper* helper) {
159 scoped_ptr<ExtensionInstallDialogView> dialog(
160 new ExtensionInstallDialogView(profile(), web_contents(),
161 helper->GetCallback(), CreatePrompt()));
162 views::DialogDelegateView* delegate_view = dialog.get();
163
164 views::Widget* modal_dialog = views::DialogDelegate::CreateDialogWidget(
165 dialog.release(), nullptr, browser()->window()->GetNativeWindow());
166 modal_dialog->Show();
167
168 return delegate_view;
169 }
170
171 private: 155 private:
172 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogViewTest); 156 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogViewTest);
173 }; 157 };
174 158
175 // Verifies that the delegate is notified when the user selects to accept or 159 // Verifies that the delegate is notified when the user selects to accept or
176 // cancel the install. 160 // cancel the install.
177 IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewTest, NotifyDelegate) { 161 IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewTest, NotifyDelegate) {
178 { 162 {
179 // User presses install.
180 ExtensionInstallPromptTestHelper helper; 163 ExtensionInstallPromptTestHelper helper;
181 views::DialogDelegateView* delegate_view = CreateAndShowPrompt(&helper); 164 scoped_ptr<ExtensionInstallDialogView> dialog(
182 delegate_view->GetDialogClientView()->AcceptWindow(); 165 new ExtensionInstallDialogView(profile(), web_contents(),
166 helper.GetCallback(),
167 CreatePrompt()));
168 views::DialogDelegateView* delegate_view = dialog.get();
169
170 delegate_view->Accept();
171 delegate_view->OnClosed();
172 dialog.reset();
173
183 EXPECT_EQ(ExtensionInstallPrompt::Result::ACCEPTED, helper.result()); 174 EXPECT_EQ(ExtensionInstallPrompt::Result::ACCEPTED, helper.result());
184 } 175 }
176
185 { 177 {
186 // User presses cancel. 178 // The user cancels the install.
187 ExtensionInstallPromptTestHelper helper; 179 ExtensionInstallPromptTestHelper helper;
188 views::DialogDelegateView* delegate_view = CreateAndShowPrompt(&helper); 180 scoped_ptr<ExtensionInstallDialogView> dialog(
189 delegate_view->GetDialogClientView()->CancelWindow(); 181 new ExtensionInstallDialogView(profile(), web_contents(),
182 helper.GetCallback(),
183 CreatePrompt()));
184 views::DialogDelegateView* delegate_view = dialog.get();
185
186 delegate_view->Cancel();
187 delegate_view->OnClosed();
188 dialog.reset();
189
190 EXPECT_EQ(ExtensionInstallPrompt::Result::USER_CANCELED, helper.result()); 190 EXPECT_EQ(ExtensionInstallPrompt::Result::USER_CANCELED, helper.result());
191 } 191 }
192
192 { 193 {
193 // Dialog is closed without the user explicitly choosing to proceed or 194 // Corner case: Dialog is closed without the user explicitly choosing to
194 // cancel. 195 // proceed or cancel.
195 ExtensionInstallPromptTestHelper helper; 196 ExtensionInstallPromptTestHelper helper;
196 views::DialogDelegateView* delegate_view = CreateAndShowPrompt(&helper); 197 scoped_ptr<ExtensionInstallDialogView> dialog(
197 delegate_view->GetWidget()->Close(); 198 new ExtensionInstallDialogView(profile(), web_contents(),
199 helper.GetCallback(),
200 CreatePrompt()));
201 dialog.reset();
202
198 // TODO(devlin): Should this be ABORTED? 203 // TODO(devlin): Should this be ABORTED?
199 EXPECT_EQ(ExtensionInstallPrompt::Result::USER_CANCELED, helper.result()); 204 EXPECT_EQ(ExtensionInstallPrompt::Result::USER_CANCELED, helper.result());
200 } 205 }
201 } 206 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/enrollment_dialog_view.cc ('k') | chrome/browser/ui/views/first_run_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698