Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Unified Diff: chrome/browser/component_updater/test/cld_component_installer_unittest.cc

Issue 333603002: Modularize Compact Language Detector 2 (CLD2) data sources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge https://codereview.chromium.org/326383005 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..bf10a9afd5f40fa9e596d22c2784335cc438369b 100644
--- a/chrome/browser/component_updater/test/cld_component_installer_unittest.cc
+++ b/chrome/browser/component_updater/test/cld_component_installer_unittest.cc
@@ -7,22 +7,28 @@
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
+#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
-#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "base/version.h"
#include "chrome/browser/component_updater/cld_component_installer.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_paths.h"
+#include "components/translate/content/browser/data_file_browser_cld_data_provider.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
+namespace {
+// This has to match what's in cld_component_installer.cc.
+const base::FilePath::CharType kTestCldDataFileName[] =
+ FILE_PATH_LITERAL("cld2_data.bin");
+} // namespace
+
namespace component_updater {
class CldComponentInstallerTest : public PlatformTest {
public:
+ CldComponentInstallerTest() {}
virtual void SetUp() OVERRIDE {
PlatformTest::SetUp();
@@ -35,77 +41,85 @@ 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());
+ component_updater::CldComponentInstallerTraits::SetLatestCldDataFile(
+ base::FilePath());
+ base::FilePath path_now =
+ translate::DataFileBrowserCldDataProvider::GetCldDataFilePath();
+ ASSERT_TRUE(path_now.empty());
}
+ protected:
base::ScopedTempDir temp_dir_;
- component_updater::CldComponentInstallerTraits traits;
+ component_updater::CldComponentInstallerTraits traits_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CldComponentInstallerTest);
};
TEST_F(CldComponentInstallerTest, SetLatestCldDataFile) {
- ASSERT_TRUE(component_updater::GetLatestCldDataFile().empty());
const base::FilePath expected(FILE_PATH_LITERAL("test/foo.test"));
- traits.SetLatestCldDataFile(expected);
-
- base::FilePath result = component_updater::GetLatestCldDataFile();
+ component_updater::CldComponentInstallerTraits::SetLatestCldDataFile(
+ expected);
+ base::FilePath result =
+ translate::DataFileBrowserCldDataProvider::GetCldDataFilePath();
ASSERT_EQ(expected, result);
}
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"));
ASSERT_TRUE(base::CreateDirectory(data_file_dir));
- const base::FilePath data_file =
- data_file_dir.Append(chrome::kCLDDataFilename);
+ const base::FilePath data_file = data_file_dir.Append(kTestCldDataFileName);
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);
- ASSERT_TRUE(EndsWith(result.value(), chrome::kCLDDataFilename, true));
+ ASSERT_TRUE(EndsWith(result.value(), kTestCldDataFileName, 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());
- base::FilePath result = component_updater::GetLatestCldDataFile();
+ traits_.ComponentReady(version, install_dir, manifest.Pass());
+ base::FilePath result =
+ translate::DataFileBrowserCldDataProvider::GetCldDataFilePath();
ASSERT_TRUE(StartsWith(result.AsUTF16Unsafe(),
install_dir.AsUTF16Unsafe(),
true));
- ASSERT_TRUE(EndsWith(result.value(), chrome::kCLDDataFilename, true));
+ ASSERT_TRUE(EndsWith(result.value(), kTestCldDataFileName, true));
}
} // namespace component_updater
« no previous file with comments | « chrome/browser/component_updater/cld_component_installer.cc ('k') | chrome/browser/policy/policy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698