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

Side by Side Diff: chrome/browser/chromeos/drive/change_list_processor_unittest.cc

Issue 17004011: drive: DriveIntegrationService owns ResourceMetadataStorage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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/chromeos/drive/change_list_processor.h" 5 #include "chrome/browser/chromeos/drive/change_list_processor.h"
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/chromeos/drive/drive.pb.h" 10 #include "chrome/browser/chromeos/drive/drive.pb.h"
(...skipping 23 matching lines...) Expand all
34 std::string path; 34 std::string path;
35 std::string id; 35 std::string id;
36 std::string parent_id; 36 std::string parent_id;
37 FileOrDirectory type; 37 FileOrDirectory type;
38 }; 38 };
39 39
40 class ChangeListProcessorTest : public testing::Test { 40 class ChangeListProcessorTest : public testing::Test {
41 protected: 41 protected:
42 virtual void SetUp() OVERRIDE { 42 virtual void SetUp() OVERRIDE {
43 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 43 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
44
45 metadata_storage_.reset(new ResourceMetadataStorage(
46 temp_dir_.path(), base::MessageLoopProxy::current()));
47 ASSERT_TRUE(metadata_storage_->Initialize());
48
44 metadata_.reset(new internal::ResourceMetadata( 49 metadata_.reset(new internal::ResourceMetadata(
45 temp_dir_.path(), base::MessageLoopProxy::current())); 50 metadata_storage_.get(), base::MessageLoopProxy::current()));
46 ASSERT_EQ(FILE_ERROR_OK, metadata_->Initialize()); 51 ASSERT_EQ(FILE_ERROR_OK, metadata_->Initialize());
47 } 52 }
48 53
49 virtual void TearDown() OVERRIDE { 54 virtual void TearDown() OVERRIDE {
50 metadata_.reset(); 55 metadata_.reset();
51 } 56 }
52 57
53 // Parses a json file at |test_data_path| relative to Chrome test directory 58 // Parses a json file at |test_data_path| relative to Chrome test directory
54 // into a ScopedVector<drive::internal::ChangeList>. 59 // into a ScopedVector<drive::internal::ChangeList>.
55 ScopedVector<ChangeList> ParseChangeList(const std::string& test_data_path) { 60 ScopedVector<ChangeList> ParseChangeList(const std::string& test_data_path) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 scoped_ptr<ResourceEntry> entry(new ResourceEntry); 96 scoped_ptr<ResourceEntry> entry(new ResourceEntry);
92 FileError error = metadata_->GetResourceEntryByPath( 97 FileError error = metadata_->GetResourceEntryByPath(
93 base::FilePath::FromUTF8Unsafe(path), entry.get()); 98 base::FilePath::FromUTF8Unsafe(path), entry.get());
94 if (error != FILE_ERROR_OK) 99 if (error != FILE_ERROR_OK)
95 entry.reset(); 100 entry.reset();
96 return entry.Pass(); 101 return entry.Pass();
97 } 102 }
98 103
99 content::TestBrowserThreadBundle thread_bundle_; 104 content::TestBrowserThreadBundle thread_bundle_;
100 base::ScopedTempDir temp_dir_; 105 base::ScopedTempDir temp_dir_;
101 scoped_ptr<internal::ResourceMetadata, test_util::DestroyHelperForTests> 106 scoped_ptr<ResourceMetadataStorage,
102 metadata_; 107 test_util::DestroyHelperForTests> metadata_storage_;
108 scoped_ptr<ResourceMetadata, test_util::DestroyHelperForTests> metadata_;
103 }; 109 };
104 110
105 } // namespace 111 } // namespace
106 112
107 TEST_F(ChangeListProcessorTest, ApplyFullResourceList) { 113 TEST_F(ChangeListProcessorTest, ApplyFullResourceList) {
108 ApplyFullResourceList(ParseChangeList(kBaseResourceListFile)); 114 ApplyFullResourceList(ParseChangeList(kBaseResourceListFile));
109 115
110 const EntryExpectation kExpected[] = { 116 const EntryExpectation kExpected[] = {
111 // Root files 117 // Root files
112 {"drive/root", 118 {"drive/root",
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 453
448 // The value is written in kTestJson. 454 // The value is written in kTestJson.
449 EXPECT_EQ(16730, metadata_->GetLargestChangestamp()); 455 EXPECT_EQ(16730, metadata_->GetLargestChangestamp());
450 EXPECT_FALSE(GetResourceEntry("drive/root/New Directory/new_pdf_file.pdf")); 456 EXPECT_FALSE(GetResourceEntry("drive/root/New Directory/new_pdf_file.pdf"));
451 457
452 EXPECT_TRUE(changed_dirs.empty()); 458 EXPECT_TRUE(changed_dirs.empty());
453 } 459 }
454 460
455 } // namespace internal 461 } // namespace internal
456 } // namespace drive 462 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698