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

Side by Side Diff: chrome/browser/translate/standalone_cld_data_harness.cc

Issue 461633002: Refactor language detection logic to allow non-static CLD data sources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make some of the harness factory methods private Created 6 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "standalone_cld_data_harness.h" 5 #include "standalone_cld_data_harness.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
12 #include "components/translate/content/common/cld_data_source.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace { 15 namespace {
15 16
16 // This has to match what's in chrome_translate_client.cc 17 // This has to match what's in chrome_translate_client.cc
17 const base::FilePath::CharType kStandaloneDataFileName[] = 18 const base::FilePath::CharType kStandaloneDataFileName[] =
18 FILE_PATH_LITERAL("cld2_data.bin"); 19 FILE_PATH_LITERAL("cld2_data.bin");
19 20
20 } // namespace 21 } // namespace
21 22
22 namespace test { 23 namespace test {
23 24
24 StandaloneCldDataHarness::StandaloneCldDataHarness() {
25 // Constructor does nothing in all cases. See Init() for initialization.
26 }
27
28 StandaloneCldDataHarness::~StandaloneCldDataHarness() { 25 StandaloneCldDataHarness::~StandaloneCldDataHarness() {
29 DVLOG(1) << "Tearing down CLD data harness"; 26 DVLOG(1) << "Tearing down CLD data harness";
30 DeleteStandaloneDataFile(); 27 DeleteStandaloneDataFile();
31 } 28 }
32 29
33 void StandaloneCldDataHarness::Init() { 30 void StandaloneCldDataHarness::Init() {
34 DVLOG(1) << "Initializing CLD data harness"; 31 DVLOG(1) << "Initializing CLD data harness";
35 // Dynamic data mode is enabled and we are using a standalone file. 32 // Dynamic data mode is enabled and we are using a standalone file.
33 translate::CldDataSource::Set(
34 translate::CldDataSource::GetStandaloneDataSource());
36 ASSERT_NO_FATAL_FAILURE(CopyStandaloneDataFile()); 35 ASSERT_NO_FATAL_FAILURE(CopyStandaloneDataFile());
37 } 36 }
38 37
39 void StandaloneCldDataHarness::GetStandaloneDataFileSource( 38 void StandaloneCldDataHarness::GetStandaloneDataFileSource(
40 base::FilePath* out_path) { 39 base::FilePath* out_path) {
41 CldDataHarness::GetTestDataSourceDirectory(out_path); 40 CldDataHarness::GetTestDataSourceDirectory(out_path);
42 *out_path = out_path->Append(FILE_PATH_LITERAL("_platform_specific")) 41 *out_path = out_path->Append(FILE_PATH_LITERAL("_platform_specific"))
43 .Append(FILE_PATH_LITERAL("all")) 42 .Append(FILE_PATH_LITERAL("all"))
44 .Append(kStandaloneDataFileName); 43 .Append(kStandaloneDataFileName);
45 } 44 }
(...skipping 21 matching lines...) Expand all
67 base::FilePath target_dir = target_file.DirName(); 66 base::FilePath target_dir = target_file.DirName();
68 ASSERT_TRUE(base::CreateDirectoryAndGetError(target_dir, NULL)); 67 ASSERT_TRUE(base::CreateDirectoryAndGetError(target_dir, NULL));
69 base::FilePath source_file; 68 base::FilePath source_file;
70 GetStandaloneDataFileSource(&source_file); 69 GetStandaloneDataFileSource(&source_file);
71 DVLOG(1) << "Copying CLD test data file from " << source_file.value() 70 DVLOG(1) << "Copying CLD test data file from " << source_file.value()
72 << " to " << target_file.value(); 71 << " to " << target_file.value();
73 ASSERT_TRUE(base::CopyFile(source_file, target_file)); 72 ASSERT_TRUE(base::CopyFile(source_file, target_file));
74 ASSERT_TRUE(base::PathExists(target_file)); 73 ASSERT_TRUE(base::PathExists(target_file));
75 } 74 }
76 75
77 scoped_ptr<CldDataHarness> CreateCldDataHarness() {
78 scoped_ptr<CldDataHarness> result(new StandaloneCldDataHarness());
79 return result.Pass();
80 }
81
82 } // namespace test 76 } // namespace test
OLDNEW
« no previous file with comments | « chrome/browser/translate/standalone_cld_data_harness.h ('k') | chrome/browser/translate/static_cld_data_harness.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698