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

Side by Side Diff: extensions/browser/guest_view/app_view/app_view_apitest.cc

Issue 1864283002: Implement <appview> based on out-of-process iframes GuestView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@extensionoptions
Patch Set: app shell test Created 4 years, 8 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 "base/command_line.h"
5 #include "base/path_service.h" 6 #include "base/path_service.h"
6 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
7 #include "components/guest_view/browser/guest_view_manager.h" 8 #include "components/guest_view/browser/guest_view_manager.h"
8 #include "components/guest_view/browser/guest_view_manager_factory.h" 9 #include "components/guest_view/browser/guest_view_manager_factory.h"
9 #include "components/guest_view/browser/test_guest_view_manager.h" 10 #include "components/guest_view/browser/test_guest_view_manager.h"
11 #include "content/public/common/content_switches.h"
10 #include "content/public/test/browser_test.h" 12 #include "content/public/test/browser_test.h"
11 #include "content/public/test/browser_test_utils.h" 13 #include "content/public/test/browser_test_utils.h"
12 #include "content/public/test/test_utils.h" 14 #include "content/public/test/test_utils.h"
13 #include "extensions/browser/app_window/app_window.h" 15 #include "extensions/browser/app_window/app_window.h"
14 #include "extensions/browser/app_window/app_window_registry.h" 16 #include "extensions/browser/app_window/app_window_registry.h"
15 #include "extensions/common/extension.h" 17 #include "extensions/common/extension.h"
16 #include "extensions/common/extension_paths.h" 18 #include "extensions/common/extension_paths.h"
17 #include "extensions/shell/browser/shell_app_delegate.h" 19 #include "extensions/shell/browser/shell_app_delegate.h"
18 #include "extensions/shell/browser/shell_app_view_guest_delegate.h" 20 #include "extensions/shell/browser/shell_app_view_guest_delegate.h"
19 #include "extensions/shell/browser/shell_content_browser_client.h" 21 #include "extensions/shell/browser/shell_content_browser_client.h"
20 #include "extensions/shell/browser/shell_extension_system.h" 22 #include "extensions/shell/browser/shell_extension_system.h"
21 #include "extensions/shell/browser/shell_extensions_api_client.h" 23 #include "extensions/shell/browser/shell_extensions_api_client.h"
22 #include "extensions/shell/browser/shell_extensions_browser_client.h" 24 #include "extensions/shell/browser/shell_extensions_browser_client.h"
23 #include "extensions/shell/test/shell_test.h" 25 #include "extensions/shell/test/shell_test.h"
24 #include "extensions/test/extension_test_message_listener.h" 26 #include "extensions/test/extension_test_message_listener.h"
25 #include "net/base/filename_util.h" 27 #include "net/base/filename_util.h"
28 #include "testing/gtest/include/gtest/gtest.h"
26 29
27 using guest_view::GuestViewManager; 30 using guest_view::GuestViewManager;
28 using guest_view::TestGuestViewManager; 31 using guest_view::TestGuestViewManager;
29 using guest_view::TestGuestViewManagerFactory; 32 using guest_view::TestGuestViewManagerFactory;
30 33
31 namespace { 34 namespace {
32 35
33 class MockShellAppDelegate : public extensions::ShellAppDelegate { 36 class MockShellAppDelegate : public extensions::ShellAppDelegate {
34 public: 37 public:
35 MockShellAppDelegate() : requested_(false) { 38 MockShellAppDelegate() : requested_(false) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 extensions::AppViewGuestDelegate* CreateAppViewGuestDelegate() 85 extensions::AppViewGuestDelegate* CreateAppViewGuestDelegate()
83 const override { 86 const override {
84 return new MockShellAppViewGuestDelegate(); 87 return new MockShellAppViewGuestDelegate();
85 } 88 }
86 }; 89 };
87 90
88 } // namespace 91 } // namespace
89 92
90 namespace extensions { 93 namespace extensions {
91 94
92 class AppViewTest : public AppShellTest { 95 class AppViewTest : public AppShellTest,
96 public testing::WithParamInterface<bool> {
93 protected: 97 protected:
94 AppViewTest() { GuestViewManager::set_factory_for_testing(&factory_); } 98 AppViewTest() { GuestViewManager::set_factory_for_testing(&factory_); }
95 99
96 TestGuestViewManager* GetGuestViewManager() { 100 TestGuestViewManager* GetGuestViewManager() {
97 return static_cast<TestGuestViewManager*>( 101 return static_cast<TestGuestViewManager*>(
98 TestGuestViewManager::FromBrowserContext( 102 TestGuestViewManager::FromBrowserContext(
99 ShellContentBrowserClient::Get()->GetBrowserContext())); 103 ShellContentBrowserClient::Get()->GetBrowserContext()));
100 } 104 }
101 105
102 content::WebContents* GetFirstAppWindowWebContents() { 106 content::WebContents* GetFirstAppWindowWebContents() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 done_listener.set_failure_message("TEST_FAILED"); 138 done_listener.set_failure_message("TEST_FAILED");
135 ASSERT_TRUE( 139 ASSERT_TRUE(
136 content::ExecuteScript(embedder_web_contents_, 140 content::ExecuteScript(embedder_web_contents_,
137 base::StringPrintf("runTest('%s', '%s')", 141 base::StringPrintf("runTest('%s', '%s')",
138 test_name.c_str(), 142 test_name.c_str(),
139 app_embedded->id().c_str()))) 143 app_embedded->id().c_str())))
140 << "Unable to start test."; 144 << "Unable to start test.";
141 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); 145 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
142 } 146 }
143 147
144 protected: 148 void SetUpCommandLine(base::CommandLine* command_line) override {
149 AppShellTest::SetUpCommandLine(command_line);
150
151 bool use_cross_process_frames_for_guests = GetParam();
152 if (use_cross_process_frames_for_guests)
153 command_line->AppendSwitch(switches::kUseCrossProcessFramesForGuests);
154 }
155
145 content::WebContents* embedder_web_contents_; 156 content::WebContents* embedder_web_contents_;
146 TestGuestViewManagerFactory factory_; 157 TestGuestViewManagerFactory factory_;
147 }; 158 };
148 159
160 INSTANTIATE_TEST_CASE_P(AppViewTests, AppViewTest, testing::Bool());
161
149 // Tests that <appview> correctly processes parameters passed on connect. 162 // Tests that <appview> correctly processes parameters passed on connect.
150 IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewGoodDataShouldSucceed) { 163 IN_PROC_BROWSER_TEST_P(AppViewTest, TestAppViewGoodDataShouldSucceed) {
151 RunTest("testAppViewGoodDataShouldSucceed", 164 RunTest("testAppViewGoodDataShouldSucceed",
152 "app_view/apitest", 165 "app_view/apitest",
153 "app_view/apitest/skeleton"); 166 "app_view/apitest/skeleton");
154 } 167 }
155 168
156 // Tests that <appview> can handle media permission requests. 169 // Tests that <appview> can handle media permission requests.
157 IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewMediaRequest) { 170 IN_PROC_BROWSER_TEST_P(AppViewTest, TestAppViewMediaRequest) {
158 static_cast<ShellExtensionsBrowserClient*>(ExtensionsBrowserClient::Get()) 171 static_cast<ShellExtensionsBrowserClient*>(ExtensionsBrowserClient::Get())
159 ->SetAPIClientForTest(nullptr); 172 ->SetAPIClientForTest(nullptr);
160 static_cast<ShellExtensionsBrowserClient*>(ExtensionsBrowserClient::Get()) 173 static_cast<ShellExtensionsBrowserClient*>(ExtensionsBrowserClient::Get())
161 ->SetAPIClientForTest(new MockExtensionsAPIClient); 174 ->SetAPIClientForTest(new MockExtensionsAPIClient);
162 175
163 RunTest("testAppViewMediaRequest", "app_view/apitest", 176 RunTest("testAppViewMediaRequest", "app_view/apitest",
164 "app_view/apitest/media_request"); 177 "app_view/apitest/media_request");
165 178
166 MockShellAppDelegate::Get()->WaitForRequestMediaPermission(); 179 MockShellAppDelegate::Get()->WaitForRequestMediaPermission();
167 } 180 }
168 181
169 // Tests that <appview> correctly processes parameters passed on connect. 182 // Tests that <appview> correctly processes parameters passed on connect.
170 // This test should fail to connect because the embedded app (skeleton) will 183 // This test should fail to connect because the embedded app (skeleton) will
171 // refuse the data passed by the embedder app and deny the request. 184 // refuse the data passed by the embedder app and deny the request.
172 IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewRefusedDataShouldFail) { 185 IN_PROC_BROWSER_TEST_P(AppViewTest, TestAppViewRefusedDataShouldFail) {
173 RunTest("testAppViewRefusedDataShouldFail", 186 RunTest("testAppViewRefusedDataShouldFail",
174 "app_view/apitest", 187 "app_view/apitest",
175 "app_view/apitest/skeleton"); 188 "app_view/apitest/skeleton");
176 } 189 }
177 190
178 // Tests that <appview> is able to navigate to another installed app. 191 // Tests that <appview> is able to navigate to another installed app.
179 IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewWithUndefinedDataShouldSucceed) { 192 IN_PROC_BROWSER_TEST_P(AppViewTest, TestAppViewWithUndefinedDataShouldSucceed) {
180 RunTest("testAppViewWithUndefinedDataShouldSucceed", 193 RunTest("testAppViewWithUndefinedDataShouldSucceed",
181 "app_view/apitest", 194 "app_view/apitest",
182 "app_view/apitest/skeleton"); 195 "app_view/apitest/skeleton");
183 } 196 }
184 197
185 } // namespace extensions 198 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/apps/guest_view/app_view_browsertest.cc ('k') | extensions/renderer/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698