Index: chrome/browser/component_updater/test/cld_component_installer_unittest.cc |
diff --git a/chrome/browser/component_updater/test/cld_component_installer_unittest.cc b/chrome/browser/component_updater/test/cld_component_installer_unittest.cc |
index 6fc4f14b73b4dcd57bae5db09d4c016425f926fc..bf3d7dc22237a279fb6c21df4bce02ce768b2781 100644 |
--- a/chrome/browser/component_updater/test/cld_component_installer_unittest.cc |
+++ b/chrome/browser/component_updater/test/cld_component_installer_unittest.cc |
@@ -8,6 +8,7 @@ |
#include "base/files/file_path.h" |
#include "base/files/scoped_temp_dir.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/path_service.h" |
#include "base/run_loop.h" |
#include "base/strings/string_util.h" |
#include "base/strings/utf_string_conversions.h" |
@@ -26,6 +27,11 @@ class CldComponentInstallerTest : public PlatformTest { |
virtual void SetUp() OVERRIDE { |
PlatformTest::SetUp(); |
+ base::FilePath base_dir; |
+ PathService::Get(chrome::DIR_COMPONENT_CLD2, &base_dir); |
+ traits.reset(new component_updater::CldComponentInstallerTraits( |
+ base_dir, base::FilePath(chrome::kCLDDataFilename))); |
+ |
// ScopedTempDir automatically does a recursive delete on the entire |
// directory in its destructor, so no cleanup is required in TearDown. |
// Note that all files created by this test case are created within the |
@@ -35,17 +41,17 @@ class CldComponentInstallerTest : public PlatformTest { |
// The "latest CLD data file" is a static piece of information, and thus |
// for correctness we empty it before each test. |
- traits.SetLatestCldDataFile(base::FilePath()); |
+ traits->SetLatestCldDataFile(base::FilePath()); |
} |
base::ScopedTempDir temp_dir_; |
- component_updater::CldComponentInstallerTraits traits; |
+ scoped_ptr<component_updater::CldComponentInstallerTraits> traits; |
}; |
TEST_F(CldComponentInstallerTest, SetLatestCldDataFile) { |
ASSERT_TRUE(component_updater::GetLatestCldDataFile().empty()); |
const base::FilePath expected(FILE_PATH_LITERAL("test/foo.test")); |
- traits.SetLatestCldDataFile(expected); |
+ traits->SetLatestCldDataFile(expected); |
base::FilePath result = component_updater::GetLatestCldDataFile(); |
ASSERT_EQ(expected, result); |
@@ -54,7 +60,7 @@ TEST_F(CldComponentInstallerTest, SetLatestCldDataFile) { |
TEST_F(CldComponentInstallerTest, VerifyInstallation) { |
// All files are created within a ScopedTempDir, which deletes all |
// children when its destructor is called (at the end of each test). |
- ASSERT_FALSE(traits.VerifyInstallation(temp_dir_.path())); |
+ ASSERT_FALSE(traits->VerifyInstallation(temp_dir_.path())); |
const base::FilePath data_file_dir = |
temp_dir_.path().Append(FILE_PATH_LITERAL("_platform_specific")).Append( |
FILE_PATH_LITERAL("all")); |
@@ -64,43 +70,42 @@ TEST_F(CldComponentInstallerTest, VerifyInstallation) { |
const std::string test_data("fake cld2 data file content here :)"); |
ASSERT_EQ(static_cast<int32>(test_data.length()), |
base::WriteFile(data_file, test_data.c_str(), test_data.length())); |
- ASSERT_TRUE(traits.VerifyInstallation(temp_dir_.path())); |
+ ASSERT_TRUE(traits->VerifyInstallation(temp_dir_.path())); |
} |
TEST_F(CldComponentInstallerTest, OnCustomInstall) { |
const base::DictionaryValue manifest; |
const base::FilePath install_dir; |
// Sanity: shouldn't crash. |
- ASSERT_TRUE(traits.OnCustomInstall(manifest, install_dir)); |
+ ASSERT_TRUE(traits->OnCustomInstall(manifest, install_dir)); |
} |
TEST_F(CldComponentInstallerTest, GetInstalledPath) { |
const base::FilePath base_dir; |
- const base::FilePath result = |
- CldComponentInstallerTraits::GetInstalledPath(base_dir); |
+ const base::FilePath result = traits->GetInstalledPath(base_dir); |
ASSERT_TRUE(EndsWith(result.value(), chrome::kCLDDataFilename, true)); |
} |
TEST_F(CldComponentInstallerTest, GetBaseDirectory) { |
- const base::FilePath result = traits.GetBaseDirectory(); |
+ const base::FilePath result = traits->GetBaseDirectory(); |
ASSERT_FALSE(result.empty()); |
} |
TEST_F(CldComponentInstallerTest, GetHash) { |
std::vector<uint8> hash; |
- traits.GetHash(&hash); |
+ traits->GetHash(&hash); |
ASSERT_EQ(static_cast<size_t>(32), hash.size()); |
} |
TEST_F(CldComponentInstallerTest, GetName) { |
- ASSERT_FALSE(traits.GetName().empty()); |
+ ASSERT_FALSE(traits->GetName().empty()); |
} |
TEST_F(CldComponentInstallerTest, ComponentReady) { |
scoped_ptr<base::DictionaryValue> manifest; |
const base::FilePath install_dir(FILE_PATH_LITERAL("/foo")); |
const base::Version version("1.2.3.4"); |
- traits.ComponentReady(version, install_dir, manifest.Pass()); |
+ traits->ComponentReady(version, install_dir, manifest.Pass()); |
base::FilePath result = component_updater::GetLatestCldDataFile(); |
ASSERT_TRUE(StartsWith(result.AsUTF16Unsafe(), |
install_dir.AsUTF16Unsafe(), |