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

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/browser/guest_view/web_view/web_view_apitest.cc » ('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() { GuestViewManager::set_factory_for_testing(&factory_); }
28
29 TestGuestViewManager* GetGuestViewManager() {
30 return static_cast<TestGuestViewManager*>(
31 TestGuestViewManager::FromBrowserContext(
32 ShellContentBrowserClient::Get()->GetBrowserContext()));
33 }
34
35 content::WebContents* GetFirstAppWindowWebContents() {
36 const AppWindowRegistry::AppWindowList& app_window_list =
37 AppWindowRegistry::Get(browser_context_)->app_windows();
38 DCHECK(app_window_list.size() == 1);
39 return (*app_window_list.begin())->web_contents();
40 }
41
42 const Extension* LoadApp(const std::string& app_location) {
43 base::FilePath test_data_dir;
44 PathService::Get(DIR_TEST_DATA, &test_data_dir);
45 test_data_dir = test_data_dir.AppendASCII(app_location.c_str());
46 return extension_system_->LoadApp(test_data_dir);
47 }
48
49 void RunTest(const std::string& test_name,
50 const std::string& app_location,
51 const std::string& app_to_embed) {
52 extension_system_->Init();
53
54 const Extension* app_embedder = LoadApp(app_location);
55 ASSERT_TRUE(app_embedder);
56 const Extension* app_embedded = LoadApp(app_to_embed);
57 ASSERT_TRUE(app_embedded);
58
59 extension_system_->LaunchApp(app_embedder->id());
60
61 ExtensionTestMessageListener launch_listener("LAUNCHED", false);
62 ASSERT_TRUE(launch_listener.WaitUntilSatisfied());
63
64 embedder_web_contents_ = GetFirstAppWindowWebContents();
65
66 ExtensionTestMessageListener done_listener("TEST_PASSED", false);
67 done_listener.set_failure_message("TEST_FAILED");
68 ASSERT_TRUE(
69 content::ExecuteScript(embedder_web_contents_,
70 base::StringPrintf("runTest('%s', '%s')",
71 test_name.c_str(),
72 app_embedded->id().c_str())))
73 << "Unable to start test.";
74 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
75 }
76
77 protected:
78 content::WebContents* embedder_web_contents_;
79 TestGuestViewManagerFactory factory_;
80 };
81
82 // Tests that <appview> correctly processes parameters passed on connect.
83 IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewGoodDataShouldSucceed) {
84 RunTest("testAppViewGoodDataShouldSucceed",
85 "app_view/apitest",
86 "app_view/apitest/skeleton");
87 }
88
89 // Tests that <appview> correctly processes parameters passed on connect.
90 // This test should fail to connect because the embedded app (skeleton) will
91 // refuse the data passed by the embedder app and deny the request.
92 IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewRefusedDataShouldFail) {
93 RunTest("testAppViewRefusedDataShouldFail",
94 "app_view/apitest",
95 "app_view/apitest/skeleton");
96 }
97
98 // Tests that <appview> is able to navigate to another installed app.
99 IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewWithUndefinedDataShouldSucceed) {
100 RunTest("testAppViewWithUndefinedDataShouldSucceed",
101 "app_view/apitest",
102 "app_view/apitest/skeleton");
103 }
104
105 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/guest_view/web_view/web_view_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698