| 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 "chrome/browser/component_updater/cld_component_installer.h" |
| 6 |
| 5 #include <stddef.h> | 7 #include <stddef.h> |
| 6 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> |
| 7 #include <vector> | 10 #include <vector> |
| 8 | 11 |
| 9 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/macros.h" | 15 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/values.h" | 19 #include "base/values.h" |
| 17 #include "base/version.h" | 20 #include "base/version.h" |
| 18 #include "chrome/browser/component_updater/cld_component_installer.h" | |
| 19 #include "components/translate/content/browser/browser_cld_data_provider.h" | 21 #include "components/translate/content/browser/browser_cld_data_provider.h" |
| 20 #include "components/translate/content/common/cld_data_source.h" | 22 #include "components/translate/content/common/cld_data_source.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "testing/platform_test.h" | 24 #include "testing/platform_test.h" |
| 23 | 25 |
| 24 using component_updater::CldComponentInstallerTraits; | 26 using component_updater::CldComponentInstallerTraits; |
| 25 | 27 |
| 26 namespace { | 28 namespace { |
| 27 | 29 |
| 28 // This has to match what's in cld_component_installer.cc. | 30 // This has to match what's in cld_component_installer.cc. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 121 } |
| 120 | 122 |
| 121 TEST_F(CldComponentInstallerTest, GetName) { | 123 TEST_F(CldComponentInstallerTest, GetName) { |
| 122 ASSERT_FALSE(traits_.GetName().empty()); | 124 ASSERT_FALSE(traits_.GetName().empty()); |
| 123 } | 125 } |
| 124 | 126 |
| 125 TEST_F(CldComponentInstallerTest, ComponentReady) { | 127 TEST_F(CldComponentInstallerTest, ComponentReady) { |
| 126 scoped_ptr<base::DictionaryValue> manifest; | 128 scoped_ptr<base::DictionaryValue> manifest; |
| 127 const base::FilePath install_dir(FILE_PATH_LITERAL("/foo")); | 129 const base::FilePath install_dir(FILE_PATH_LITERAL("/foo")); |
| 128 const base::Version version("1.2.3.4"); | 130 const base::Version version("1.2.3.4"); |
| 129 traits_.ComponentReady(version, install_dir, manifest.Pass()); | 131 traits_.ComponentReady(version, install_dir, std::move(manifest)); |
| 130 base::FilePath result = CldComponentInstallerTraits::GetLatestCldDataFile(); | 132 base::FilePath result = CldComponentInstallerTraits::GetLatestCldDataFile(); |
| 131 ASSERT_TRUE(base::StartsWith(result.AsUTF16Unsafe(), | 133 ASSERT_TRUE(base::StartsWith(result.AsUTF16Unsafe(), |
| 132 install_dir.AsUTF16Unsafe(), | 134 install_dir.AsUTF16Unsafe(), |
| 133 base::CompareCase::SENSITIVE)); | 135 base::CompareCase::SENSITIVE)); |
| 134 ASSERT_TRUE(base::EndsWith(result.value(), kTestCldDataFileName, | 136 ASSERT_TRUE(base::EndsWith(result.value(), kTestCldDataFileName, |
| 135 base::CompareCase::SENSITIVE)); | 137 base::CompareCase::SENSITIVE)); |
| 136 } | 138 } |
| 137 | 139 |
| 138 } // namespace component_updater | 140 } // namespace component_updater |
| OLD | NEW |