| 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 "chrome/browser/component_updater/flash_component_installer.h" | 5 #include "chrome/browser/component_updater/flash_component_installer.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 FILE_PATH_LITERAL("components/flapper/NONEXISTENT"); | 36 FILE_PATH_LITERAL("components/flapper/NONEXISTENT"); |
| 37 #endif | 37 #endif |
| 38 #endif | 38 #endif |
| 39 } | 39 } |
| 40 | 40 |
| 41 // TODO(viettrungluu): Separate out into two separate tests; use a test fixture. | 41 // TODO(viettrungluu): Separate out into two separate tests; use a test fixture. |
| 42 TEST(ComponentInstallerTest, PepperFlashCheck) { | 42 TEST(ComponentInstallerTest, PepperFlashCheck) { |
| 43 MessageLoop message_loop; | 43 MessageLoop message_loop; |
| 44 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 44 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
| 45 | 45 |
| 46 ppapi::PpapiGlobals::ForTest for_test; | 46 ppapi::PpapiGlobals::ForPerThreadTest for_per_thread_test; |
| 47 ppapi::TestGlobals test_globals(for_test); | 47 ppapi::TestGlobals test_globals(for_per_thread_test); |
| 48 ppapi::PpapiGlobals::SetPpapiGlobalsOnThreadForTest(&test_globals); | 48 ppapi::PpapiGlobals::SetPpapiGlobalsOnThreadForTest(&test_globals); |
| 49 | 49 |
| 50 // The test directory is chrome/test/data/components/flapper. | 50 // The test directory is chrome/test/data/components/flapper. |
| 51 FilePath manifest; | 51 FilePath manifest; |
| 52 PathService::Get(chrome::DIR_TEST_DATA, &manifest); | 52 PathService::Get(chrome::DIR_TEST_DATA, &manifest); |
| 53 manifest = manifest.Append(kDataPath); | 53 manifest = manifest.Append(kDataPath); |
| 54 manifest = manifest.AppendASCII("manifest.json"); | 54 manifest = manifest.AppendASCII("manifest.json"); |
| 55 | 55 |
| 56 if (!file_util::PathExists(manifest)) { | 56 if (!file_util::PathExists(manifest)) { |
| 57 LOG(WARNING) << "No test manifest available. Skipping."; | 57 LOG(WARNING) << "No test manifest available. Skipping."; |
| 58 return; | 58 return; |
| 59 } | 59 } |
| 60 | 60 |
| 61 JSONFileValueSerializer serializer(manifest); | 61 JSONFileValueSerializer serializer(manifest); |
| 62 std::string error; | 62 std::string error; |
| 63 scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error)); | 63 scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error)); |
| 64 ASSERT_TRUE(root.get() != NULL); | 64 ASSERT_TRUE(root.get() != NULL); |
| 65 ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); | 65 ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); |
| 66 | 66 |
| 67 // This checks that the whole manifest is compatible. | 67 // This checks that the whole manifest is compatible. |
| 68 Version version; | 68 Version version; |
| 69 EXPECT_TRUE(CheckPepperFlashManifest( | 69 EXPECT_TRUE(CheckPepperFlashManifest( |
| 70 static_cast<base::DictionaryValue*>(root.get()), &version)); | 70 static_cast<base::DictionaryValue*>(root.get()), &version)); |
| 71 EXPECT_TRUE(version.IsValid()); | 71 EXPECT_TRUE(version.IsValid()); |
| 72 } | 72 } |
| OLD | NEW |