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

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

Issue 643703007: Adding app_view tests to app_shell_browsertests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multiple_apps
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | extensions/shell/app_shell.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/path_service.h"
6 #include "base/strings/stringprintf.h"
7 #include "content/public/test/browser_test.h"
8 #include "content/public/test/browser_test_utils.h"
9 #include "content/public/test/test_utils.h"
10 #include "extensions/browser/app_window/app_window.h"
11 #include "extensions/browser/app_window/app_window_registry.h"
12 #include "extensions/browser/guest_view/guest_view_manager.h"
13 #include "extensions/browser/guest_view/guest_view_manager_factory.h"
14 #include "extensions/browser/guest_view/test_guest_view_manager.h"
15 #include "extensions/common/extension.h"
16 #include "extensions/common/extension_paths.h"
17 #include "extensions/shell/browser/shell_content_browser_client.h"
18 #include "extensions/shell/browser/shell_extension_system.h"
19 #include "extensions/shell/test/shell_test.h"
20 #include "extensions/test/extension_test_message_listener.h"
21 #include "net/base/filename_util.h"
22
23 namespace extensions {
24
25 class AppViewTest : public AppShellTest {
26 protected:
27 AppViewTest() {
28 extensions::GuestViewManager::set_factory_for_testing(&factory_);
Yoyo Zhou 2014/10/29 20:37:58 nit: don't need extensions::
lfg 2014/10/30 23:38:16 Done.
29 }
30
31 TestGuestViewManager* GetGuestViewManager() {
32 return static_cast<TestGuestViewManager*>(
33 TestGuestViewManager::FromBrowserContext(
34 ShellContentBrowserClient::Get()->GetBrowserContext()));
35 }
36
37 content::WebContents* GetFirstAppWindowWebContents() {
38 const AppWindowRegistry::AppWindowList& app_window_list =
39 AppWindowRegistry::Get(browser_context_)->app_windows();
40 DCHECK(app_window_list.size() == 1);
41 return (*app_window_list.begin())->web_contents();
42 }
43
44 const Extension* LoadApp(const std::string& app_location) {
45 base::FilePath test_data_dir;
46 PathService::Get(DIR_TEST_DATA, &test_data_dir);
47 test_data_dir = test_data_dir.AppendASCII(app_location.c_str());
48 return extension_system_->LoadApp(test_data_dir);
49 }
50
51 void RunTest(const std::string& test_name,
52 const std::string& app_location,
53 const std::string& app_to_embed) {
54 extension_system_->Init();
55
56 const Extension* app_embedder = LoadApp(app_location);
57 ASSERT_TRUE(app_embedder);
58 const Extension* app_embedded = LoadApp(app_to_embed);
59 ASSERT_TRUE(app_embedded);
60
61 extension_system_->LaunchApp(app_embedder->id());
62
63 ExtensionTestMessageListener launch_listener("LAUNCHED", false);
64 ASSERT_TRUE(launch_listener.WaitUntilSatisfied());
65
66 embedder_web_contents_ = GetFirstAppWindowWebContents();
67
68 ExtensionTestMessageListener done_listener("TEST_PASSED", false);
69 done_listener.set_failure_message("TEST_FAILED");
70 if (!content::ExecuteScript(
71 embedder_web_contents_,
72 base::StringPrintf("runTest('%s', '%s')",
73 test_name.c_str(),
74 app_embedded->id().c_str()))) {
75 LOG(ERROR) << "Unable to start test.";
Yoyo Zhou 2014/10/29 20:37:58 Does this actually make the test fail? It might be
lfg 2014/10/30 23:38:16 Done. web_view_apitest had the same issue, so I fi
76 return;
77 }
78 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
79 }
80
81 protected:
82 content::WebContents* embedder_web_contents_;
83 TestGuestViewManagerFactory factory_;
84 };
85
86 // Tests that <appview> correctly processes parameters passed on connect.
87 IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewGoodDataShouldSucceed) {
88 RunTest("testAppViewGoodDataShouldSucceed",
89 "app_view/apitest",
90 "app_view/apitest/skeleton");
91 }
92
93 // Tests that <appview> correctly processes parameters passed on connect.
94 // This test should fail to connect because the embedded app (skeleton) will
95 // refuse the data passed by the embedder app and deny the request.
96 IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewRefusedDataShouldFail) {
97 RunTest("testAppViewRefusedDataShouldFail",
98 "app_view/apitest",
99 "app_view/apitest/skeleton");
100 }
101
102 // Tests that <appview> is able to navigate to another installed app.
103 IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewWithUndefinedDataShouldSucceed) {
104 RunTest("testAppViewWithUndefinedDataShouldSucceed",
105 "app_view/apitest",
106 "app_view/apitest/skeleton");
107 }
108
109 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/shell/app_shell.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698