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

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: Use base/memory/scoped_ptr.h, not base/scoped_ptr.h 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..7791f14027030079b69415a0c3d41029b38bd6b9 100644
--- a/chrome/browser/component_updater/test/cld_component_installer_unittest.cc
+++ b/chrome/browser/component_updater/test/cld_component_installer_unittest.cc
@@ -16,6 +16,7 @@
#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"
@@ -33,21 +34,25 @@ class CldComponentInstallerTest : public PlatformTest {
// created *as temp files*, they will still get cleaned up automagically.
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
+ cld_data_file_name =
+ component_updater::CldComponentInstallerTraits::GetCldDataFileName();
+
// 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());
}
Takashi Toyoshima 2014/06/23 08:50:00 following members can be protected.
Andrew Hayden (chromium.org) 2014/06/23 13:20:35 Done.
+ const base::FilePath::CharType* cld_data_file_name;
Takashi Toyoshima 2014/06/23 08:50:00 cld_data_file_name_
Andrew Hayden (chromium.org) 2014/06/23 13:20:35 Now that I've removed the getter from cld_componen
base::ScopedTempDir temp_dir_;
component_updater::CldComponentInstallerTraits traits;
Takashi Toyoshima 2014/06/23 08:50:00 traits_
Andrew Hayden (chromium.org) 2014/06/23 13:20:34 Done.
};
Takashi Toyoshima 2014/06/23 08:50:00 DISALLOW_...
Andrew Hayden (chromium.org) 2014/06/23 13:20:34 Done.
TEST_F(CldComponentInstallerTest, SetLatestCldDataFile) {
- ASSERT_TRUE(component_updater::GetLatestCldDataFile().empty());
Takashi Toyoshima 2014/06/23 08:50:00 I'm not sure it is worth doing, but this check can
Andrew Hayden (chromium.org) 2014/06/23 13:20:35 Added equivalent check to setup.
const base::FilePath expected(FILE_PATH_LITERAL("test/foo.test"));
traits.SetLatestCldDataFile(expected);
- base::FilePath result = component_updater::GetLatestCldDataFile();
+ base::FilePath result =
+ translate::DataFileBrowserCldDataProvider::GetCldDataFilePath();
ASSERT_EQ(expected, result);
}
@@ -60,7 +65,7 @@ TEST_F(CldComponentInstallerTest, VerifyInstallation) {
FILE_PATH_LITERAL("all"));
ASSERT_TRUE(base::CreateDirectory(data_file_dir));
const base::FilePath data_file =
Takashi Toyoshima 2014/06/23 08:50:00 no line break
Andrew Hayden (chromium.org) 2014/06/23 13:20:35 Done.
- data_file_dir.Append(chrome::kCLDDataFilename);
+ data_file_dir.Append(cld_data_file_name);
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()));
@@ -78,7 +83,7 @@ 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(), cld_data_file_name, true));
}
TEST_F(CldComponentInstallerTest, GetBaseDirectory) {
@@ -101,11 +106,12 @@ TEST_F(CldComponentInstallerTest, ComponentReady) {
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();
+ 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(), cld_data_file_name, true));
}
} // namespace component_updater

Powered by Google App Engine
This is Rietveld 408576698