| 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 "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
| 9 #include "chrome/browser/extensions/extension_icon_manager.h" | 9 #include "chrome/browser/extensions/extension_icon_manager.h" |
| 10 #include "chrome/browser/extensions/extension_install_prompt.h" | 10 #include "chrome/browser/extensions/extension_install_prompt.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 ScrollbarTest::ScrollbarTest() | 158 ScrollbarTest::ScrollbarTest() |
| 159 : ExtensionInstallDialogViewTestBase( | 159 : ExtensionInstallDialogViewTestBase( |
| 160 ExtensionInstallPrompt::PERMISSIONS_PROMPT) { | 160 ExtensionInstallPrompt::PERMISSIONS_PROMPT) { |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool ScrollbarTest::IsScrollbarVisible() { | 163 bool ScrollbarTest::IsScrollbarVisible() { |
| 164 ExtensionInstallPrompt::ShowParams show_params(web_contents()); | 164 ExtensionInstallPrompt::ShowParams show_params(web_contents()); |
| 165 ExtensionInstallDialogView* dialog = new ExtensionInstallDialogView( | 165 ExtensionInstallDialogView* dialog = new ExtensionInstallDialogView( |
| 166 show_params.navigator, delegate(), prompt()); | 166 show_params.profile, |
| 167 show_params.parent_web_contents, |
| 168 delegate(), |
| 169 prompt()); |
| 167 | 170 |
| 168 // Create the modal view around the install dialog view. | 171 // Create the modal view around the install dialog view. |
| 169 views::Widget* modal = | 172 views::Widget* modal = |
| 170 CreateBrowserModalDialogViews(dialog, show_params.parent_window); | 173 CreateBrowserModalDialogViews(dialog, show_params.parent_window); |
| 171 modal->Show(); | 174 modal->Show(); |
| 172 content::RunAllBlockingPoolTasksUntilIdle(); | 175 content::RunAllBlockingPoolTasksUntilIdle(); |
| 173 | 176 |
| 174 // Check if the vertical scrollbar is visible. | 177 // Check if the vertical scrollbar is visible. |
| 175 return dialog->scroll_view()->vertical_scroll_bar()->visible(); | 178 return dialog->scroll_view()->vertical_scroll_bar()->visible(); |
| 176 } | 179 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogViewTest); | 219 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogViewTest); |
| 217 }; | 220 }; |
| 218 | 221 |
| 219 // Verifies that the delegate is notified when the user selects to accept or | 222 // Verifies that the delegate is notified when the user selects to accept or |
| 220 // cancel the install. | 223 // cancel the install. |
| 221 IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewTest, NotifyDelegate) { | 224 IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewTest, NotifyDelegate) { |
| 222 { | 225 { |
| 223 // The user confirms the install. | 226 // The user confirms the install. |
| 224 MockExtensionInstallPromptDelegate delegate; | 227 MockExtensionInstallPromptDelegate delegate; |
| 225 scoped_ptr<ExtensionInstallDialogView> dialog( | 228 scoped_ptr<ExtensionInstallDialogView> dialog( |
| 226 new ExtensionInstallDialogView(web_contents(), &delegate, prompt())); | 229 new ExtensionInstallDialogView( |
| 230 profile(), web_contents(), &delegate, prompt())); |
| 227 views::DialogDelegateView* delegate_view = dialog.get(); | 231 views::DialogDelegateView* delegate_view = dialog.get(); |
| 228 | 232 |
| 229 delegate_view->Accept(); | 233 delegate_view->Accept(); |
| 230 delegate_view->OnClosed(); | 234 delegate_view->OnClosed(); |
| 231 dialog.reset(); | 235 dialog.reset(); |
| 232 | 236 |
| 233 EXPECT_EQ(0, delegate.abort_count()); | 237 EXPECT_EQ(0, delegate.abort_count()); |
| 234 EXPECT_EQ(1, delegate.proceed_count()); | 238 EXPECT_EQ(1, delegate.proceed_count()); |
| 235 } | 239 } |
| 236 | 240 |
| 237 { | 241 { |
| 238 // The user cancels the install. | 242 // The user cancels the install. |
| 239 MockExtensionInstallPromptDelegate delegate; | 243 MockExtensionInstallPromptDelegate delegate; |
| 240 scoped_ptr<ExtensionInstallDialogView> dialog( | 244 scoped_ptr<ExtensionInstallDialogView> dialog( |
| 241 new ExtensionInstallDialogView(web_contents(), &delegate, prompt())); | 245 new ExtensionInstallDialogView( |
| 246 profile(), web_contents(), &delegate, prompt())); |
| 242 views::DialogDelegateView* delegate_view = dialog.get(); | 247 views::DialogDelegateView* delegate_view = dialog.get(); |
| 243 | 248 |
| 244 delegate_view->Cancel(); | 249 delegate_view->Cancel(); |
| 245 delegate_view->OnClosed(); | 250 delegate_view->OnClosed(); |
| 246 dialog.reset(); | 251 dialog.reset(); |
| 247 | 252 |
| 248 EXPECT_EQ(1, delegate.abort_count()); | 253 EXPECT_EQ(1, delegate.abort_count()); |
| 249 EXPECT_EQ(0, delegate.proceed_count()); | 254 EXPECT_EQ(0, delegate.proceed_count()); |
| 250 } | 255 } |
| 251 | 256 |
| 252 { | 257 { |
| 253 // Corner case: Dialog is closed without the user explicitly choosing to | 258 // Corner case: Dialog is closed without the user explicitly choosing to |
| 254 // proceed or cancel. | 259 // proceed or cancel. |
| 255 MockExtensionInstallPromptDelegate delegate; | 260 MockExtensionInstallPromptDelegate delegate; |
| 256 scoped_ptr<ExtensionInstallDialogView> dialog( | 261 scoped_ptr<ExtensionInstallDialogView> dialog( |
| 257 new ExtensionInstallDialogView(web_contents(), &delegate, prompt())); | 262 new ExtensionInstallDialogView( |
| 263 profile(), web_contents(), &delegate, prompt())); |
| 258 dialog.reset(); | 264 dialog.reset(); |
| 259 | 265 |
| 260 EXPECT_EQ(1, delegate.abort_count()); | 266 EXPECT_EQ(1, delegate.abort_count()); |
| 261 EXPECT_EQ(0, delegate.proceed_count()); | 267 EXPECT_EQ(0, delegate.proceed_count()); |
| 262 } | 268 } |
| 263 } | 269 } |
| OLD | NEW |