| 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 "base/threading/thread_restrictions.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
| 16 #include "content/public/test/ppapi_test_utils.h" | 17 #include "content/public/test/ppapi_test_utils.h" |
| 17 #include "content/shell/browser/shell.h" | 18 #include "content/shell/browser/shell.h" |
| 18 #include "net/base/filename_util.h" | 19 #include "net/base/filename_util.h" |
| 19 #include "ppapi/shared_impl/ppapi_switches.h" | 20 #include "ppapi/shared_impl/ppapi_switches.h" |
| 20 | 21 |
| 21 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
| 22 #include "chromeos/audio/cras_audio_handler.h" | 23 #include "chromeos/audio/cras_audio_handler.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 53 command_line->AppendSwitch(switches::kDisableSmoothScrolling); | 54 command_line->AppendSwitch(switches::kDisableSmoothScrolling); |
| 54 | 55 |
| 55 // Allow manual garbage collection. | 56 // Allow manual garbage collection. |
| 56 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose_gc"); | 57 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose_gc"); |
| 57 | 58 |
| 58 command_line->AppendSwitch(switches::kUseFakeUIForMediaStream); | 59 command_line->AppendSwitch(switches::kUseFakeUIForMediaStream); |
| 59 } | 60 } |
| 60 | 61 |
| 61 GURL PPAPITestBase::GetTestFileUrl(const std::string& test_case) { | 62 GURL PPAPITestBase::GetTestFileUrl(const std::string& test_case) { |
| 62 base::FilePath test_path; | 63 base::FilePath test_path; |
| 63 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_path)); | 64 { |
| 64 test_path = test_path.Append(FILE_PATH_LITERAL("ppapi")); | 65 base::ThreadRestrictions::ScopedAllowIO allow_io_for_test_setup; |
| 65 test_path = test_path.Append(FILE_PATH_LITERAL("tests")); | |
| 66 test_path = test_path.Append(FILE_PATH_LITERAL("test_case.html")); | |
| 67 | 66 |
| 68 // Sanity check the file name. | 67 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_path)); |
| 69 EXPECT_TRUE(base::PathExists(test_path)); | 68 test_path = test_path.Append(FILE_PATH_LITERAL("ppapi")); |
| 69 test_path = test_path.Append(FILE_PATH_LITERAL("tests")); |
| 70 test_path = test_path.Append(FILE_PATH_LITERAL("test_case.html")); |
| 71 |
| 72 // Sanity check the file name. |
| 73 EXPECT_TRUE(base::PathExists(test_path)); |
| 74 } |
| 75 |
| 70 GURL test_url = net::FilePathToFileURL(test_path); | 76 GURL test_url = net::FilePathToFileURL(test_path); |
| 71 | 77 |
| 72 GURL::Replacements replacements; | 78 GURL::Replacements replacements; |
| 73 std::string query = BuildQuery(std::string(), test_case); | 79 std::string query = BuildQuery(std::string(), test_case); |
| 74 replacements.SetQuery(query.c_str(), url::Component(0, query.size())); | 80 replacements.SetQuery(query.c_str(), url::Component(0, query.size())); |
| 75 return test_url.ReplaceComponents(replacements); | 81 return test_url.ReplaceComponents(replacements); |
| 76 } | 82 } |
| 77 | 83 |
| 78 void PPAPITestBase::RunTest(const std::string& test_case) { | 84 void PPAPITestBase::RunTest(const std::string& test_case) { |
| 79 GURL url = GetTestFileUrl(test_case); | 85 GURL url = GetTestFileUrl(test_case); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 135 } |
| 130 | 136 |
| 131 void OutOfProcessPPAPITest::TearDown() { | 137 void OutOfProcessPPAPITest::TearDown() { |
| 132 ContentBrowserTest::TearDown(); | 138 ContentBrowserTest::TearDown(); |
| 133 #if defined(OS_CHROMEOS) | 139 #if defined(OS_CHROMEOS) |
| 134 chromeos::CrasAudioHandler::Shutdown(); | 140 chromeos::CrasAudioHandler::Shutdown(); |
| 135 #endif | 141 #endif |
| 136 } | 142 } |
| 137 | 143 |
| 138 } // namespace content | 144 } // namespace content |
| OLD | NEW |