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

Side by Side Diff: components/offline_pages/core/archive_manager_unittest.cc

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: more rebase Created 4 years 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/offline_pages/archive_manager.h" 5 #include "components/offline_pages/core/archive_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/files/scoped_temp_dir.h" 15 #include "base/files/scoped_temp_dir.h"
16 #include "base/test/test_simple_task_runner.h" 16 #include "base/test/test_simple_task_runner.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 namespace offline_pages { 20 namespace offline_pages {
21 21
22 namespace { 22 namespace {
23 const base::FilePath::CharType kMissingArchivePath[] = FILE_PATH_LITERAL( 23 const base::FilePath::CharType kMissingArchivePath[] =
24 "missing_archive.path"); 24 FILE_PATH_LITERAL("missing_archive.path");
25 } // namespace 25 } // namespace
26 26
27 enum class CallbackStatus { 27 enum class CallbackStatus {
28 NOT_CALLED, 28 NOT_CALLED,
29 CALLED_FALSE, 29 CALLED_FALSE,
30 CALLED_TRUE, 30 CALLED_TRUE,
31 }; 31 };
32 32
33 class ArchiveManagerTest : public testing::Test { 33 class ArchiveManagerTest : public testing::Test {
34 public: 34 public:
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 base::Bind(&ArchiveManagerTest::Callback, base::Unretained(this))); 181 base::Bind(&ArchiveManagerTest::Callback, base::Unretained(this)));
182 PumpLoop(); 182 PumpLoop();
183 EXPECT_EQ(CallbackStatus::CALLED_TRUE, callback_status()); 183 EXPECT_EQ(CallbackStatus::CALLED_TRUE, callback_status());
184 EXPECT_FALSE(base::PathExists(archive_path_1)); 184 EXPECT_FALSE(base::PathExists(archive_path_1));
185 EXPECT_FALSE(base::PathExists(archive_path_2)); 185 EXPECT_FALSE(base::PathExists(archive_path_2));
186 EXPECT_TRUE(base::PathExists(archive_path_3)); 186 EXPECT_TRUE(base::PathExists(archive_path_3));
187 } 187 }
188 188
189 TEST_F(ArchiveManagerTest, DeleteMultipleArchivesNoneExist) { 189 TEST_F(ArchiveManagerTest, DeleteMultipleArchivesNoneExist) {
190 base::FilePath archive_path_1 = temp_path().Append(kMissingArchivePath); 190 base::FilePath archive_path_1 = temp_path().Append(kMissingArchivePath);
191 base::FilePath archive_path_2 = temp_path().Append(FILE_PATH_LITERAL( 191 base::FilePath archive_path_2 =
192 "other_missing_file.mhtml")); 192 temp_path().Append(FILE_PATH_LITERAL("other_missing_file.mhtml"));
193 base::FilePath archive_path_3; 193 base::FilePath archive_path_3;
194 EXPECT_TRUE(base::CreateTemporaryFileInDir(temp_path(), &archive_path_3)); 194 EXPECT_TRUE(base::CreateTemporaryFileInDir(temp_path(), &archive_path_3));
195 195
196 std::vector<base::FilePath> archive_paths = {archive_path_1, archive_path_2}; 196 std::vector<base::FilePath> archive_paths = {archive_path_1, archive_path_2};
197 197
198 EXPECT_FALSE(base::PathExists(archive_path_1)); 198 EXPECT_FALSE(base::PathExists(archive_path_1));
199 EXPECT_FALSE(base::PathExists(archive_path_2)); 199 EXPECT_FALSE(base::PathExists(archive_path_2));
200 200
201 manager()->DeleteMultipleArchives( 201 manager()->DeleteMultipleArchives(
202 archive_paths, 202 archive_paths,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 265
266 manager()->GetStorageStats(base::Bind( 266 manager()->GetStorageStats(base::Bind(
267 &ArchiveManagerTest::GetStorageStatsCallback, base::Unretained(this))); 267 &ArchiveManagerTest::GetStorageStatsCallback, base::Unretained(this)));
268 PumpLoop(); 268 PumpLoop();
269 EXPECT_GT(last_storage_sizes().free_disk_space, 0); 269 EXPECT_GT(last_storage_sizes().free_disk_space, 0);
270 EXPECT_EQ(last_storage_sizes().total_archives_size, 270 EXPECT_EQ(last_storage_sizes().total_archives_size,
271 base::ComputeDirectorySize(temp_path())); 271 base::ComputeDirectorySize(temp_path()));
272 } 272 }
273 273
274 } // namespace offline_pages 274 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698