OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
10 #include "base/message_loop/message_loop.h" | |
11 #include "base/path_service.h" | 10 #include "base/path_service.h" |
12 #include "base/version.h" | 11 #include "base/version.h" |
13 #include "build/build_config.h" | 12 #include "build/build_config.h" |
14 #include "chrome/browser/component_updater/pepper_flash_component_installer.h" | 13 #include "chrome/browser/component_updater/pepper_flash_component_installer.h" |
15 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
16 #include "chrome/common/pepper_flash.h" | 15 #include "chrome/common/pepper_flash.h" |
17 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
18 #include "ppapi/shared_impl/test_globals.h" | 17 #include "ppapi/shared_impl/test_globals.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
20 | 19 |
21 using content::BrowserThread; | |
22 | |
23 namespace component_updater { | 20 namespace component_updater { |
24 | 21 |
25 namespace { | 22 namespace { |
26 // File name of the Pepper Flash plugin on different platforms. | 23 // File name of the Pepper Flash plugin on different platforms. |
27 const base::FilePath::CharType kDataPath[] = | 24 const base::FilePath::CharType kDataPath[] = |
28 #if defined(OS_MACOSX) | 25 #if defined(OS_MACOSX) |
29 #if defined(ARCH_CPU_X86) | 26 #if defined(ARCH_CPU_X86) |
30 FILE_PATH_LITERAL("components/flapper/mac"); | 27 FILE_PATH_LITERAL("components/flapper/mac"); |
31 #elif defined(ARCH_CPU_X86_64) | 28 #elif defined(ARCH_CPU_X86_64) |
32 FILE_PATH_LITERAL("components/flapper/mac_x64"); | 29 FILE_PATH_LITERAL("components/flapper/mac_x64"); |
(...skipping 24 matching lines...) Expand all Loading... |
57 #elif defined(ARCH_CPU_X86_64) | 54 #elif defined(ARCH_CPU_X86_64) |
58 FILE_PATH_LITERAL("components/flapper/linux_x64"); | 55 FILE_PATH_LITERAL("components/flapper/linux_x64"); |
59 #else | 56 #else |
60 FILE_PATH_LITERAL("components/flapper/NONEXISTENT"); | 57 FILE_PATH_LITERAL("components/flapper/NONEXISTENT"); |
61 #endif | 58 #endif |
62 #endif | 59 #endif |
63 } // namespace | 60 } // namespace |
64 | 61 |
65 // TODO(viettrungluu): Separate out into two separate tests; use a test fixture. | 62 // TODO(viettrungluu): Separate out into two separate tests; use a test fixture. |
66 TEST(ComponentInstallerTest, PepperFlashCheck) { | 63 TEST(ComponentInstallerTest, PepperFlashCheck) { |
67 base::MessageLoop message_loop; | 64 content::TestBrowserThreadBundle test_browser_thread_bundle; |
68 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | |
69 | 65 |
70 ppapi::PpapiGlobals::PerThreadForTest per_thread_for_test; | 66 ppapi::PpapiGlobals::PerThreadForTest per_thread_for_test; |
71 ppapi::TestGlobals test_globals(per_thread_for_test); | 67 ppapi::TestGlobals test_globals(per_thread_for_test); |
72 ppapi::PpapiGlobals::SetPpapiGlobalsOnThreadForTest(&test_globals); | 68 ppapi::PpapiGlobals::SetPpapiGlobalsOnThreadForTest(&test_globals); |
73 | 69 |
74 // The test directory is chrome/test/data/components/flapper. | 70 // The test directory is chrome/test/data/components/flapper. |
75 base::FilePath manifest; | 71 base::FilePath manifest; |
76 PathService::Get(chrome::DIR_TEST_DATA, &manifest); | 72 PathService::Get(chrome::DIR_TEST_DATA, &manifest); |
77 manifest = manifest.Append(kDataPath); | 73 manifest = manifest.Append(kDataPath); |
78 manifest = manifest.AppendASCII("manifest.json"); | 74 manifest = manifest.AppendASCII("manifest.json"); |
(...skipping 12 matching lines...) Expand all Loading... |
91 ASSERT_TRUE(root); | 87 ASSERT_TRUE(root); |
92 ASSERT_TRUE(root->IsType(base::Value::Type::DICTIONARY)); | 88 ASSERT_TRUE(root->IsType(base::Value::Type::DICTIONARY)); |
93 | 89 |
94 // This checks that the whole manifest is compatible. | 90 // This checks that the whole manifest is compatible. |
95 base::Version version; | 91 base::Version version; |
96 EXPECT_TRUE(chrome::CheckPepperFlashManifest(*root, &version)); | 92 EXPECT_TRUE(chrome::CheckPepperFlashManifest(*root, &version)); |
97 EXPECT_TRUE(version.IsValid()); | 93 EXPECT_TRUE(version.IsValid()); |
98 } | 94 } |
99 | 95 |
100 } // namespace component_updater | 96 } // namespace component_updater |
OLD | NEW |