| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/website_settings/permission_bubble_browser_test_util
.h" | 5 #include "chrome/browser/ui/website_settings/permission_bubble_browser_test_util
.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
| 11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 12 #include "chrome/browser/ui/extensions/app_launch_params.h" | 12 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 13 #include "chrome/browser/ui/extensions/application_launch.h" | 13 #include "chrome/browser/ui/extensions/application_launch.h" |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "chrome/browser/ui/website_settings/mock_permission_bubble_request.h" | 15 #include "chrome/browser/ui/website_settings/mock_permission_bubble_request.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 | 19 |
| 20 TestPermissionBubbleViewDelegate::TestPermissionBubbleViewDelegate() | 20 TestPermissionBubbleViewDelegate::TestPermissionBubbleViewDelegate() |
| 21 : PermissionBubbleView::Delegate() { | 21 : PermissionBubbleView::Delegate() { |
| 22 } | 22 } |
| 23 | 23 |
| 24 PermissionBubbleBrowserTest::PermissionBubbleBrowserTest() | 24 PermissionBubbleBrowserTest::PermissionBubbleBrowserTest() { |
| 25 : InProcessBrowserTest() { | |
| 26 } | 25 } |
| 27 | 26 |
| 28 PermissionBubbleBrowserTest::~PermissionBubbleBrowserTest() { | 27 PermissionBubbleBrowserTest::~PermissionBubbleBrowserTest() { |
| 29 } | 28 } |
| 30 | 29 |
| 31 void PermissionBubbleBrowserTest::SetUpOnMainThread() { | 30 void PermissionBubbleBrowserTest::SetUpOnMainThread() { |
| 32 InProcessBrowserTest::SetUpOnMainThread(); | 31 ExtensionBrowserTest::SetUpOnMainThread(); |
| 33 | 32 |
| 34 // Add a single permission request. | 33 // Add a single permission request. |
| 35 MockPermissionBubbleRequest* request = new MockPermissionBubbleRequest( | 34 MockPermissionBubbleRequest* request = new MockPermissionBubbleRequest( |
| 36 "Request 1", l10n_util::GetStringUTF8(IDS_PERMISSION_ALLOW), | 35 "Request 1", l10n_util::GetStringUTF8(IDS_PERMISSION_ALLOW), |
| 37 l10n_util::GetStringUTF8(IDS_PERMISSION_DENY)); | 36 l10n_util::GetStringUTF8(IDS_PERMISSION_DENY)); |
| 38 requests_.push_back(request); | 37 requests_.push_back(request); |
| 39 } | 38 } |
| 40 | 39 |
| 41 PermissionBubbleAppBrowserTest::PermissionBubbleAppBrowserTest() | 40 Browser* PermissionBubbleBrowserTest::OpenExtensionAppWindow() { |
| 42 : InProcessBrowserTest(), | |
| 43 PermissionBubbleBrowserTest(), | |
| 44 ExtensionBrowserTest(), | |
| 45 app_browser_(nullptr) { | |
| 46 } | |
| 47 | |
| 48 PermissionBubbleAppBrowserTest::~PermissionBubbleAppBrowserTest() { | |
| 49 } | |
| 50 | |
| 51 void PermissionBubbleAppBrowserTest::SetUpOnMainThread() { | |
| 52 PermissionBubbleBrowserTest::SetUpOnMainThread(); | |
| 53 ExtensionBrowserTest::SetUpOnMainThread(); | |
| 54 | |
| 55 auto extension = | 41 auto extension = |
| 56 LoadExtension(test_data_dir_.AppendASCII("app_with_panel_container/")); | 42 LoadExtension(test_data_dir_.AppendASCII("app_with_panel_container/")); |
| 57 ASSERT_TRUE(extension); | 43 CHECK(extension); |
| 58 | |
| 59 app_browser_ = OpenExtensionAppWindow(extension); | |
| 60 ASSERT_TRUE(app_browser()); | |
| 61 ASSERT_TRUE(app_browser()->is_app()); | |
| 62 } | |
| 63 | |
| 64 void PermissionBubbleAppBrowserTest::SetUp() { | |
| 65 ExtensionBrowserTest::SetUp(); | |
| 66 } | |
| 67 | |
| 68 void PermissionBubbleAppBrowserTest::SetUpCommandLine( | |
| 69 base::CommandLine* command_line) { | |
| 70 ExtensionBrowserTest::SetUpCommandLine(command_line); | |
| 71 } | |
| 72 | |
| 73 Browser* PermissionBubbleAppBrowserTest::OpenExtensionAppWindow( | |
| 74 const extensions::Extension* extension) { | |
| 75 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | |
| 76 command_line.AppendSwitchASCII(switches::kAppId, extension->id()); | |
| 77 | 44 |
| 78 AppLaunchParams params(browser()->profile(), extension, | 45 AppLaunchParams params(browser()->profile(), extension, |
| 79 extensions::LAUNCH_CONTAINER_PANEL, NEW_WINDOW, | 46 extensions::LAUNCH_CONTAINER_PANEL, NEW_WINDOW, |
| 80 extensions::SOURCE_COMMAND_LINE); | 47 extensions::SOURCE_TEST); |
| 81 params.command_line = command_line; | |
| 82 params.current_directory = base::FilePath(); | |
| 83 | 48 |
| 84 content::WebContents* app_window = OpenApplication(params); | 49 content::WebContents* app_window = OpenApplication(params); |
| 85 assert(app_window); | 50 CHECK(app_window); |
| 86 | 51 |
| 87 return chrome::FindBrowserWithWebContents(app_window); | 52 Browser* app_browser = chrome::FindBrowserWithWebContents(app_window); |
| 53 CHECK(app_browser); |
| 54 CHECK(app_browser->is_app()); |
| 55 |
| 56 return app_browser; |
| 88 } | 57 } |
| 89 | 58 |
| 90 PermissionBubbleKioskBrowserTest::PermissionBubbleKioskBrowserTest() | 59 PermissionBubbleKioskBrowserTest::PermissionBubbleKioskBrowserTest() { |
| 91 : PermissionBubbleBrowserTest() { | |
| 92 } | 60 } |
| 93 | 61 |
| 94 PermissionBubbleKioskBrowserTest::~PermissionBubbleKioskBrowserTest() { | 62 PermissionBubbleKioskBrowserTest::~PermissionBubbleKioskBrowserTest() { |
| 95 } | 63 } |
| 96 | 64 |
| 97 void PermissionBubbleKioskBrowserTest::SetUpCommandLine( | 65 void PermissionBubbleKioskBrowserTest::SetUpCommandLine( |
| 98 base::CommandLine* command_line) { | 66 base::CommandLine* command_line) { |
| 99 PermissionBubbleBrowserTest::SetUpCommandLine(command_line); | 67 PermissionBubbleBrowserTest::SetUpCommandLine(command_line); |
| 100 command_line->AppendSwitch(switches::kKioskMode); | 68 command_line->AppendSwitch(switches::kKioskMode); |
| 101 } | 69 } |
| OLD | NEW |