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

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

Issue 701483002: [chrome/browser/translate, chrome/browser/thumbnails] Convert VLOGs to DVLOGs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comments 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
« no previous file with comments | « chrome/browser/translate/component_cld_data_harness.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace { 14 namespace {
15 15
16 // This has to match what's in chrome_translate_client.cc 16 // This has to match what's in chrome_translate_client.cc
17 const base::FilePath::CharType kStandaloneDataFileName[] = 17 const base::FilePath::CharType kStandaloneDataFileName[] =
18 FILE_PATH_LITERAL("cld2_data.bin"); 18 FILE_PATH_LITERAL("cld2_data.bin");
19 19
20 } // namespace 20 } // namespace
21 21
22 namespace test { 22 namespace test {
23 23
24 StandaloneCldDataHarness::StandaloneCldDataHarness() { 24 StandaloneCldDataHarness::StandaloneCldDataHarness() {
25 // Constructor does nothing in all cases. See Init() for initialization. 25 // Constructor does nothing in all cases. See Init() for initialization.
26 } 26 }
27 27
28 StandaloneCldDataHarness::~StandaloneCldDataHarness() { 28 StandaloneCldDataHarness::~StandaloneCldDataHarness() {
29 VLOG(1) << "Tearing down CLD data harness"; 29 DVLOG(1) << "Tearing down CLD data harness";
30 DeleteStandaloneDataFile(); 30 DeleteStandaloneDataFile();
31 } 31 }
32 32
33 void StandaloneCldDataHarness::Init() { 33 void StandaloneCldDataHarness::Init() {
34 VLOG(1) << "Initializing CLD data harness"; 34 DVLOG(1) << "Initializing CLD data harness";
35 // Dynamic data mode is enabled and we are using a standalone file. 35 // Dynamic data mode is enabled and we are using a standalone file.
36 ASSERT_NO_FATAL_FAILURE(CopyStandaloneDataFile()); 36 ASSERT_NO_FATAL_FAILURE(CopyStandaloneDataFile());
37 } 37 }
38 38
39 void StandaloneCldDataHarness::GetStandaloneDataFileSource( 39 void StandaloneCldDataHarness::GetStandaloneDataFileSource(
40 base::FilePath* out_path) { 40 base::FilePath* out_path) {
41 CldDataHarness::GetTestDataSourceDirectory(out_path); 41 CldDataHarness::GetTestDataSourceDirectory(out_path);
42 *out_path = out_path->Append(FILE_PATH_LITERAL("_platform_specific")) 42 *out_path = out_path->Append(FILE_PATH_LITERAL("_platform_specific"))
43 .Append(FILE_PATH_LITERAL("all")) 43 .Append(FILE_PATH_LITERAL("all"))
44 .Append(kStandaloneDataFileName); 44 .Append(kStandaloneDataFileName);
45 } 45 }
46 46
47 // Using the USER_DATA_DIR not only mimics true functionality, but also is 47 // Using the USER_DATA_DIR not only mimics true functionality, but also is
48 // important to test isolation. Each test gets its own USER_DATA_DIR, which 48 // important to test isolation. Each test gets its own USER_DATA_DIR, which
49 // ensures proper isolation between test processes running in parallel. 49 // ensures proper isolation between test processes running in parallel.
50 void StandaloneCldDataHarness::GetStandaloneDataFileDestination( 50 void StandaloneCldDataHarness::GetStandaloneDataFileDestination(
51 base::FilePath* out_path) { 51 base::FilePath* out_path) {
52 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, out_path)); 52 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, out_path));
53 *out_path = out_path->Append(kStandaloneDataFileName); 53 *out_path = out_path->Append(kStandaloneDataFileName);
54 } 54 }
55 55
56 void StandaloneCldDataHarness::DeleteStandaloneDataFile() { 56 void StandaloneCldDataHarness::DeleteStandaloneDataFile() {
57 base::FilePath path; 57 base::FilePath path;
58 ASSERT_NO_FATAL_FAILURE(GetStandaloneDataFileDestination(&path)); 58 ASSERT_NO_FATAL_FAILURE(GetStandaloneDataFileDestination(&path));
59 VLOG(1) << "Deleting CLD test data file from " << path.value(); 59 DVLOG(1) << "Deleting CLD test data file from " << path.value();
60 base::DeleteFile(path, false); 60 base::DeleteFile(path, false);
61 } 61 }
62 62
63 void StandaloneCldDataHarness::CopyStandaloneDataFile() { 63 void StandaloneCldDataHarness::CopyStandaloneDataFile() {
64 DeleteStandaloneDataFile(); // sanity: blow away any old copies. 64 DeleteStandaloneDataFile(); // sanity: blow away any old copies.
65 base::FilePath target_file; 65 base::FilePath target_file;
66 GetStandaloneDataFileDestination(&target_file); 66 GetStandaloneDataFileDestination(&target_file);
67 base::FilePath target_dir = target_file.DirName(); 67 base::FilePath target_dir = target_file.DirName();
68 ASSERT_TRUE(base::CreateDirectoryAndGetError(target_dir, NULL)); 68 ASSERT_TRUE(base::CreateDirectoryAndGetError(target_dir, NULL));
69 base::FilePath source_file; 69 base::FilePath source_file;
70 GetStandaloneDataFileSource(&source_file); 70 GetStandaloneDataFileSource(&source_file);
71 VLOG(1) << "Copying CLD test data file from " << source_file.value() << " to " 71 DVLOG(1) << "Copying CLD test data file from " << source_file.value()
72 << target_file.value(); 72 << " to " << target_file.value();
73 ASSERT_TRUE(base::CopyFile(source_file, target_file)); 73 ASSERT_TRUE(base::CopyFile(source_file, target_file));
74 ASSERT_TRUE(base::PathExists(target_file)); 74 ASSERT_TRUE(base::PathExists(target_file));
75 } 75 }
76 76
77 scoped_ptr<CldDataHarness> CreateCldDataHarness() { 77 scoped_ptr<CldDataHarness> CreateCldDataHarness() {
78 scoped_ptr<CldDataHarness> result(new StandaloneCldDataHarness()); 78 scoped_ptr<CldDataHarness> result(new StandaloneCldDataHarness());
79 return result.Pass(); 79 return result.Pass();
80 } 80 }
81 81
82 } // namespace test 82 } // namespace test
OLDNEW
« no previous file with comments | « chrome/browser/translate/component_cld_data_harness.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698