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 "content/test/ppapi/ppapi_test.h" | 5 #include "content/test/ppapi/ppapi_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "content/public/test/ppapi_test_utils.h" |
15 #include "content/shell/browser/shell.h" | 16 #include "content/shell/browser/shell.h" |
16 #include "net/base/filename_util.h" | 17 #include "net/base/filename_util.h" |
17 #include "ppapi/shared_impl/ppapi_switches.h" | 18 #include "ppapi/shared_impl/ppapi_switches.h" |
18 #include "ppapi/shared_impl/test_harness_utils.h" | |
19 | 19 |
20 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) |
21 #include "chromeos/audio/cras_audio_handler.h" | 21 #include "chromeos/audio/cras_audio_handler.h" |
22 #endif | 22 #endif |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 | 25 |
26 PPAPITestMessageHandler::PPAPITestMessageHandler() { | 26 PPAPITestMessageHandler::PPAPITestMessageHandler() { |
27 } | 27 } |
28 | 28 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 ASSERT_TRUE(observer.Run()) << handler.error_message(); | 97 ASSERT_TRUE(observer.Run()) << handler.error_message(); |
98 EXPECT_STREQ("PASS", handler.message().c_str()); | 98 EXPECT_STREQ("PASS", handler.message().c_str()); |
99 } | 99 } |
100 | 100 |
101 PPAPITest::PPAPITest() : in_process_(true) { | 101 PPAPITest::PPAPITest() : in_process_(true) { |
102 } | 102 } |
103 | 103 |
104 void PPAPITest::SetUpCommandLine(base::CommandLine* command_line) { | 104 void PPAPITest::SetUpCommandLine(base::CommandLine* command_line) { |
105 PPAPITestBase::SetUpCommandLine(command_line); | 105 PPAPITestBase::SetUpCommandLine(command_line); |
106 | 106 ASSERT_TRUE(ppapi::RegisterTestPlugin(command_line)); |
107 // Append the switch to register the pepper plugin. | |
108 // library name = <out dir>/<test_name>.<library_extension> | |
109 // MIME type = application/x-ppapi-<test_name> | |
110 base::FilePath plugin_dir; | |
111 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); | |
112 | |
113 base::FilePath plugin_lib = plugin_dir.Append(ppapi::GetTestLibraryName()); | |
114 EXPECT_TRUE(base::PathExists(plugin_lib)); | |
115 base::FilePath::StringType pepper_plugin = plugin_lib.value(); | |
116 pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests")); | |
117 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, | |
118 pepper_plugin); | |
119 | 107 |
120 if (in_process_) | 108 if (in_process_) |
121 command_line->AppendSwitch(switches::kPpapiInProcess); | 109 command_line->AppendSwitch(switches::kPpapiInProcess); |
122 } | 110 } |
123 | 111 |
124 std::string PPAPITest::BuildQuery(const std::string& base, | 112 std::string PPAPITest::BuildQuery(const std::string& base, |
125 const std::string& test_case){ | 113 const std::string& test_case){ |
126 return base::StringPrintf("%stestcase=%s", base.c_str(), test_case.c_str()); | 114 return base::StringPrintf("%stestcase=%s", base.c_str(), test_case.c_str()); |
127 } | 115 } |
128 | 116 |
129 OutOfProcessPPAPITest::OutOfProcessPPAPITest() { | 117 OutOfProcessPPAPITest::OutOfProcessPPAPITest() { |
130 in_process_ = false; | 118 in_process_ = false; |
131 } | 119 } |
132 | 120 |
133 void OutOfProcessPPAPITest::SetUp() { | 121 void OutOfProcessPPAPITest::SetUp() { |
134 #if defined(OS_CHROMEOS) | 122 #if defined(OS_CHROMEOS) |
135 chromeos::CrasAudioHandler::InitializeForTesting(); | 123 chromeos::CrasAudioHandler::InitializeForTesting(); |
136 #endif | 124 #endif |
137 ContentBrowserTest::SetUp(); | 125 ContentBrowserTest::SetUp(); |
138 } | 126 } |
139 | 127 |
140 void OutOfProcessPPAPITest::TearDown() { | 128 void OutOfProcessPPAPITest::TearDown() { |
141 ContentBrowserTest::TearDown(); | 129 ContentBrowserTest::TearDown(); |
142 #if defined(OS_CHROMEOS) | 130 #if defined(OS_CHROMEOS) |
143 chromeos::CrasAudioHandler::Shutdown(); | 131 chromeos::CrasAudioHandler::Shutdown(); |
144 #endif | 132 #endif |
145 } | 133 } |
146 | 134 |
147 } // namespace content | 135 } // namespace content |
OLD | NEW |