OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/component_updater/sth_set_component_installer.h" | 5 #include "chrome/browser/component_updater/sth_set_component_installer.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 traits_.reset(new STHSetComponentInstallerTraits(observer_.get())); | 48 traits_.reset(new STHSetComponentInstallerTraits(observer_.get())); |
49 } | 49 } |
50 | 50 |
51 void WriteSTHToFile(const std::string& sth_json, | 51 void WriteSTHToFile(const std::string& sth_json, |
52 const base::FilePath& filename) { | 52 const base::FilePath& filename) { |
53 ASSERT_EQ(static_cast<int32_t>(sth_json.length()), | 53 ASSERT_EQ(static_cast<int32_t>(sth_json.length()), |
54 base::WriteFile(filename, sth_json.data(), sth_json.length())); | 54 base::WriteFile(filename, sth_json.data(), sth_json.length())); |
55 } | 55 } |
56 | 56 |
57 base::FilePath GetSTHsDir() { | 57 base::FilePath GetSTHsDir() { |
58 return temp_dir_.path() | 58 return temp_dir_.GetPath() |
59 .Append(FILE_PATH_LITERAL("_platform_specific")) | 59 .Append(FILE_PATH_LITERAL("_platform_specific")) |
60 .Append(FILE_PATH_LITERAL("all")) | 60 .Append(FILE_PATH_LITERAL("all")) |
61 .Append(FILE_PATH_LITERAL("sths")); | 61 .Append(FILE_PATH_LITERAL("sths")); |
62 } | 62 } |
63 | 63 |
64 void CreateSTHsDir(const base::DictionaryValue& manifest, | 64 void CreateSTHsDir(const base::DictionaryValue& manifest, |
65 const base::FilePath& sths_dir) { | 65 const base::FilePath& sths_dir) { |
66 ASSERT_FALSE(traits_->VerifyInstallation(manifest, temp_dir_.path())); | 66 ASSERT_FALSE(traits_->VerifyInstallation(manifest, temp_dir_.GetPath())); |
67 ASSERT_TRUE(base::CreateDirectory(sths_dir)); | 67 ASSERT_TRUE(base::CreateDirectory(sths_dir)); |
68 } | 68 } |
69 | 69 |
70 void LoadSTHs(const base::DictionaryValue& manifest, | 70 void LoadSTHs(const base::DictionaryValue& manifest, |
71 const base::FilePath& sths_dir) { | 71 const base::FilePath& sths_dir) { |
72 ASSERT_TRUE(traits_->VerifyInstallation(manifest, temp_dir_.path())); | 72 ASSERT_TRUE(traits_->VerifyInstallation(manifest, temp_dir_.GetPath())); |
73 | 73 |
74 const base::Version v("1.0"); | 74 const base::Version v("1.0"); |
75 traits_->LoadSTHsFromDisk(sths_dir, v); | 75 traits_->LoadSTHsFromDisk(sths_dir, v); |
76 // Drain the RunLoop created by the TestBrowserThreadBundle | 76 // Drain the RunLoop created by the TestBrowserThreadBundle |
77 base::RunLoop().RunUntilIdle(); | 77 base::RunLoop().RunUntilIdle(); |
78 } | 78 } |
79 | 79 |
80 protected: | 80 protected: |
81 content::TestBrowserThreadBundle thread_bundle_; | 81 content::TestBrowserThreadBundle thread_bundle_; |
82 | 82 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 const base::FilePath not_hex_sth_file = | 143 const base::FilePath not_hex_sth_file = |
144 sths_dir.Append(FILE_PATH_LITERAL("nothex.sth")); | 144 sths_dir.Append(FILE_PATH_LITERAL("nothex.sth")); |
145 WriteSTHToFile(net::ct::GetSampleSTHAsJson(), not_hex_sth_file); | 145 WriteSTHToFile(net::ct::GetSampleSTHAsJson(), not_hex_sth_file); |
146 | 146 |
147 LoadSTHs(manifest, sths_dir); | 147 LoadSTHs(manifest, sths_dir); |
148 EXPECT_EQ(0u, observer_->sths.size()); | 148 EXPECT_EQ(0u, observer_->sths.size()); |
149 } | 149 } |
150 | 150 |
151 } // namespace component_updater | 151 } // namespace component_updater |
OLD | NEW |