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

Side by Side Diff: components/update_client/test/test_installer.cc

Issue 1102103002: Move the unit tests files side-by-side with the corresponding .cc files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments from waffles Created 5 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/update_client/test/test_installer.h"
6
7 #include <string>
8
9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h"
11 #include "base/values.h"
12
13 namespace update_client {
14
15 TestInstaller::TestInstaller() : error_(0), install_count_(0) {
16 }
17
18 void TestInstaller::OnUpdateError(int error) {
19 error_ = error;
20 }
21
22 bool TestInstaller::Install(const base::DictionaryValue& manifest,
23 const base::FilePath& unpack_path) {
24 ++install_count_;
25 return base::DeleteFile(unpack_path, true);
26 }
27
28 bool TestInstaller::GetInstalledFile(const std::string& file,
29 base::FilePath* installed_file) {
30 return false;
31 }
32
33 TestInstaller::~TestInstaller() {
34 }
35
36 bool TestInstaller::Uninstall() {
37 return false;
38 }
39
40 ReadOnlyTestInstaller::ReadOnlyTestInstaller(const base::FilePath& install_dir)
41 : install_directory_(install_dir) {
42 }
43
44 ReadOnlyTestInstaller::~ReadOnlyTestInstaller() {
45 }
46
47 bool ReadOnlyTestInstaller::GetInstalledFile(const std::string& file,
48 base::FilePath* installed_file) {
49 *installed_file = install_directory_.AppendASCII(file);
50 return true;
51 }
52
53 VersionedTestInstaller::VersionedTestInstaller() {
54 base::CreateNewTempDirectory(FILE_PATH_LITERAL("TEST_"), &install_directory_);
55 }
56
57 VersionedTestInstaller::~VersionedTestInstaller() {
58 base::DeleteFile(install_directory_, true);
59 }
60
61 bool VersionedTestInstaller::Install(const base::DictionaryValue& manifest,
62 const base::FilePath& unpack_path) {
63 std::string version_string;
64 manifest.GetStringASCII("version", &version_string);
65 Version version(version_string.c_str());
66
67 base::FilePath path;
68 path = install_directory_.AppendASCII(version.GetString());
69 base::CreateDirectory(path.DirName());
70 if (!base::Move(unpack_path, path))
71 return false;
72 current_version_ = version;
73 ++install_count_;
74 return true;
75 }
76
77 bool VersionedTestInstaller::GetInstalledFile(const std::string& file,
78 base::FilePath* installed_file) {
79 base::FilePath path;
80 path = install_directory_.AppendASCII(current_version_.GetString());
81 *installed_file = path.Append(base::FilePath::FromUTF8Unsafe(file));
82 return true;
83 }
84
85 } // namespace update_client
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698