| Index: apps/saved_files_service_unittest.cc
|
| diff --git a/apps/saved_files_service_unittest.cc b/apps/saved_files_service_unittest.cc
|
| index fe215c661defb9a0d1edd3f504aa625cedbeedce..f21cea8c6c27480c1b1acac2e6d615c53008463c 100644
|
| --- a/apps/saved_files_service_unittest.cc
|
| +++ b/apps/saved_files_service_unittest.cc
|
| @@ -4,13 +4,14 @@
|
|
|
| #include <algorithm>
|
|
|
| -#include "apps/saved_files_service.h"
|
| +#include "apps/saved_files_service_impl.h"
|
| #include "base/files/file_path.h"
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/test/values_test_util.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/extensions/test_extension_environment.h"
|
| #include "chrome/test/base/testing_profile.h"
|
| +#include "extensions/browser/api/file_system/saved_files_service.h"
|
| #include "extensions/browser/extension_prefs.h"
|
| #include "extensions/browser/extension_system.h"
|
| #include "extensions/common/extension.h"
|
| @@ -22,8 +23,9 @@
|
| expression; \
|
| } while (0)
|
|
|
| -using apps::SavedFileEntry;
|
| -using apps::SavedFilesService;
|
| +using apps::SavedFilesServiceImpl;
|
| +using extensions::SavedFilesService;
|
| +using Entry = extensions::SavedFilesService::Entry;
|
|
|
| namespace {
|
|
|
| @@ -33,7 +35,7 @@ std::string GenerateId(int i) {
|
|
|
| } // namespace
|
|
|
| -class SavedFilesServiceUnitTest : public testing::Test {
|
| +class SavedFilesServiceImplUnitTest : public testing::Test {
|
| protected:
|
| void SetUp() override {
|
| testing::Test::SetUp();
|
| @@ -48,13 +50,13 @@ class SavedFilesServiceUnitTest : public testing::Test {
|
| " {\"fileSystem\": [\"retainEntries\"]}"
|
| " ]"
|
| "}"));
|
| - service_ = SavedFilesService::Get(env_.profile());
|
| + service_ = SavedFilesServiceImpl::Get(env_.profile());
|
| path_ = base::FilePath(FILE_PATH_LITERAL("filename.ext"));
|
| }
|
|
|
| void TearDown() override {
|
| - SavedFilesService::ClearMaxSequenceNumberForTest();
|
| - SavedFilesService::ClearLruSizeForTest();
|
| + SavedFilesServiceImpl::ClearMaxSequenceNumberForTest();
|
| + SavedFilesServiceImpl::ClearLruSizeForTest();
|
| testing::Test::TearDown();
|
| }
|
|
|
| @@ -63,8 +65,7 @@ class SavedFilesServiceUnitTest : public testing::Test {
|
| std::string id_string = GenerateId(id);
|
| SCOPED_TRACE(id_string);
|
| EXPECT_TRUE(service_->IsRegistered(extension_->id(), id_string));
|
| - const SavedFileEntry* entry =
|
| - service_->GetFileEntry(extension_->id(), id_string);
|
| + const Entry* entry = service_->GetFileEntry(extension_->id(), id_string);
|
| ASSERT_TRUE(entry);
|
| EXPECT_EQ(id_string, entry->id);
|
| EXPECT_EQ(path_, entry->path);
|
| @@ -74,7 +75,7 @@ class SavedFilesServiceUnitTest : public testing::Test {
|
|
|
| // Check that a range of registered file entries have the correct values.
|
| void CheckRangeEnqueuedInOrder(int start, int end) {
|
| - SavedFileEntry entry;
|
| + Entry entry;
|
| for (int i = start; i < end; i++) {
|
| CheckEntrySequenceNumber(i, i + 1);
|
| }
|
| @@ -82,11 +83,11 @@ class SavedFilesServiceUnitTest : public testing::Test {
|
|
|
| extensions::TestExtensionEnvironment env_;
|
| const extensions::Extension* extension_;
|
| - SavedFilesService* service_;
|
| + SavedFilesServiceImpl* service_;
|
| base::FilePath path_;
|
| };
|
|
|
| -TEST_F(SavedFilesServiceUnitTest, RetainTwoFilesTest) {
|
| +TEST_F(SavedFilesServiceImplUnitTest, RetainTwoFilesTest) {
|
| service_->RegisterFileEntry(extension_->id(), GenerateId(1), path_, true);
|
| service_->RegisterFileEntry(extension_->id(), GenerateId(2), path_, true);
|
| service_->RegisterFileEntry(extension_->id(), GenerateId(3), path_, true);
|
| @@ -126,7 +127,7 @@ TEST_F(SavedFilesServiceUnitTest, RetainTwoFilesTest) {
|
| TRACE_CALL(CheckEntrySequenceNumber(3, 0));
|
|
|
| EXPECT_FALSE(service_->IsRegistered(extension_->id(), "another id"));
|
| - SavedFileEntry entry;
|
| + Entry entry;
|
| EXPECT_FALSE(service_->GetFileEntry(extension_->id(), "another id"));
|
|
|
| // ClearQueueIfNoRetainPermission should be a no-op because the app has the
|
| @@ -145,13 +146,13 @@ TEST_F(SavedFilesServiceUnitTest, RetainTwoFilesTest) {
|
| EXPECT_FALSE(service_->IsRegistered(extension_->id(), GenerateId(3)));
|
| }
|
|
|
| -TEST_F(SavedFilesServiceUnitTest, NoRetainEntriesPermissionTest) {
|
| +TEST_F(SavedFilesServiceImplUnitTest, NoRetainEntriesPermissionTest) {
|
| extension_ = env_.MakeExtension(*base::test::ParseJson(
|
| "{\"app\": {\"background\": {\"scripts\": [\"background.js\"]}},"
|
| "\"permissions\": [\"fileSystem\"]}"));
|
| service_->RegisterFileEntry(extension_->id(), GenerateId(1), path_, true);
|
| TRACE_CALL(CheckEntrySequenceNumber(1, 0));
|
| - SavedFileEntry entry;
|
| + Entry entry;
|
| service_->EnqueueFileEntry(extension_->id(), GenerateId(1));
|
| TRACE_CALL(CheckEntrySequenceNumber(1, 1));
|
| EXPECT_FALSE(service_->IsRegistered(extension_->id(), "another id"));
|
| @@ -160,13 +161,12 @@ TEST_F(SavedFilesServiceUnitTest, NoRetainEntriesPermissionTest) {
|
| // ClearQueueIfNoRetainPermission should clear the queue, since the app does
|
| // not have the "retainEntries" permission.
|
| service_->ClearQueueIfNoRetainPermission(extension_);
|
| - std::vector<SavedFileEntry> entries =
|
| - service_->GetAllFileEntries(extension_->id());
|
| + std::vector<Entry> entries = service_->GetAllFileEntries(extension_->id());
|
| EXPECT_TRUE(entries.empty());
|
| }
|
|
|
| -TEST_F(SavedFilesServiceUnitTest, EvictionTest) {
|
| - SavedFilesService::SetLruSizeForTest(10);
|
| +TEST_F(SavedFilesServiceImplUnitTest, EvictionTest) {
|
| + SavedFilesServiceImpl::SetLruSizeForTest(10);
|
| for (int i = 0; i < 10; i++) {
|
| service_->RegisterFileEntry(extension_->id(), GenerateId(i), path_, true);
|
| service_->EnqueueFileEntry(extension_->id(), GenerateId(i));
|
| @@ -184,7 +184,7 @@ TEST_F(SavedFilesServiceUnitTest, EvictionTest) {
|
|
|
| // Check that retained entries are unchanged after a clear.
|
| service_->Clear(extension_->id());
|
| - SavedFileEntry entry;
|
| + Entry entry;
|
| EXPECT_FALSE(service_->GetFileEntry(extension_->id(), GenerateId(0)));
|
| TRACE_CALL(CheckRangeEnqueuedInOrder(1, 11));
|
|
|
| @@ -202,9 +202,9 @@ TEST_F(SavedFilesServiceUnitTest, EvictionTest) {
|
| TRACE_CALL(CheckRangeEnqueuedInOrder(3, 11));
|
| }
|
|
|
| -TEST_F(SavedFilesServiceUnitTest, SequenceNumberCompactionTest) {
|
| - SavedFilesService::SetMaxSequenceNumberForTest(8);
|
| - SavedFilesService::SetLruSizeForTest(8);
|
| +TEST_F(SavedFilesServiceImplUnitTest, SequenceNumberCompactionTest) {
|
| + SavedFilesServiceImpl::SetMaxSequenceNumberForTest(8);
|
| + SavedFilesServiceImpl::SetLruSizeForTest(8);
|
| for (int i = 0; i < 4; i++) {
|
| service_->RegisterFileEntry(extension_->id(), GenerateId(i), path_, true);
|
| service_->EnqueueFileEntry(extension_->id(), GenerateId(i));
|
|
|