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

Side by Side Diff: components/drive/resource_metadata_unittest.cc

Issue 1546143002: Switch to standard integer types in components/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/drive/resource_metadata.h" 5 #include "components/drive/resource_metadata.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include <algorithm> 10 #include <algorithm>
8 #include <string> 11 #include <string>
9 #include <vector> 12 #include <vector>
10 13
11 #include "base/files/scoped_temp_dir.h" 14 #include "base/files/scoped_temp_dir.h"
12 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
13 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
14 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
15 #include "components/drive/drive.pb.h" 18 #include "components/drive/drive.pb.h"
16 #include "components/drive/drive_test_util.h" 19 #include "components/drive/drive_test_util.h"
17 #include "components/drive/fake_free_disk_space_getter.h" 20 #include "components/drive/fake_free_disk_space_getter.h"
18 #include "components/drive/file_cache.h" 21 #include "components/drive/file_cache.h"
19 #include "components/drive/file_system_core_util.h" 22 #include "components/drive/file_system_core_util.h"
20 #include "content/public/test/test_browser_thread_bundle.h" 23 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
22 25
23 namespace drive { 26 namespace drive {
24 namespace internal { 27 namespace internal {
25 namespace { 28 namespace {
26 29
27 // The changestamp of the resource metadata used in 30 // The changestamp of the resource metadata used in
28 // ResourceMetadataTest. 31 // ResourceMetadataTest.
29 const int64 kTestChangestamp = 100; 32 const int64_t kTestChangestamp = 100;
30 33
31 // Returns the sorted base names from |entries|. 34 // Returns the sorted base names from |entries|.
32 std::vector<std::string> GetSortedBaseNames( 35 std::vector<std::string> GetSortedBaseNames(
33 const ResourceEntryVector& entries) { 36 const ResourceEntryVector& entries) {
34 std::vector<std::string> base_names; 37 std::vector<std::string> base_names;
35 for (size_t i = 0; i < entries.size(); ++i) 38 for (size_t i = 0; i < entries.size(); ++i)
36 base_names.push_back(entries[i].base_name()); 39 base_names.push_back(entries[i].base_name());
37 std::sort(base_names.begin(), base_names.end()); 40 std::sort(base_names.begin(), base_names.end());
38 41
39 return base_names; 42 return base_names;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 content::TestBrowserThreadBundle thread_bundle_; 166 content::TestBrowserThreadBundle thread_bundle_;
164 scoped_ptr<ResourceMetadataStorage, test_util::DestroyHelperForTests> 167 scoped_ptr<ResourceMetadataStorage, test_util::DestroyHelperForTests>
165 metadata_storage_; 168 metadata_storage_;
166 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_; 169 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_;
167 scoped_ptr<FileCache, test_util::DestroyHelperForTests> cache_; 170 scoped_ptr<FileCache, test_util::DestroyHelperForTests> cache_;
168 scoped_ptr<ResourceMetadata, test_util::DestroyHelperForTests> 171 scoped_ptr<ResourceMetadata, test_util::DestroyHelperForTests>
169 resource_metadata_; 172 resource_metadata_;
170 }; 173 };
171 174
172 TEST_F(ResourceMetadataTest, LargestChangestamp) { 175 TEST_F(ResourceMetadataTest, LargestChangestamp) {
173 const int64 kChangestamp = 123456; 176 const int64_t kChangestamp = 123456;
174 EXPECT_EQ(FILE_ERROR_OK, 177 EXPECT_EQ(FILE_ERROR_OK,
175 resource_metadata_->SetLargestChangestamp(kChangestamp)); 178 resource_metadata_->SetLargestChangestamp(kChangestamp));
176 int64 changestamp = 0; 179 int64_t changestamp = 0;
177 EXPECT_EQ(FILE_ERROR_OK, 180 EXPECT_EQ(FILE_ERROR_OK,
178 resource_metadata_->GetLargestChangestamp(&changestamp)); 181 resource_metadata_->GetLargestChangestamp(&changestamp));
179 EXPECT_EQ(kChangestamp, changestamp); 182 EXPECT_EQ(kChangestamp, changestamp);
180 } 183 }
181 184
182 TEST_F(ResourceMetadataTest, GetResourceEntryByPath) { 185 TEST_F(ResourceMetadataTest, GetResourceEntryByPath) {
183 // Confirm that an existing file is found. 186 // Confirm that an existing file is found.
184 ResourceEntry entry; 187 ResourceEntry entry;
185 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->GetResourceEntryByPath( 188 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->GetResourceEntryByPath(
186 base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"), &entry)); 189 base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"), &entry));
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 std::vector<ResourceEntry> entries; 668 std::vector<ResourceEntry> entries;
666 ASSERT_EQ(FILE_ERROR_OK, 669 ASSERT_EQ(FILE_ERROR_OK,
667 resource_metadata_->ReadDirectoryByPath( 670 resource_metadata_->ReadDirectoryByPath(
668 base::FilePath::FromUTF8Unsafe("drive/root"), &entries)); 671 base::FilePath::FromUTF8Unsafe("drive/root"), &entries));
669 ASSERT_FALSE(entries.empty()); 672 ASSERT_FALSE(entries.empty());
670 673
671 // Reset. 674 // Reset.
672 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->Reset()); 675 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->Reset());
673 676
674 // change stamp should be reset. 677 // change stamp should be reset.
675 int64 changestamp = 0; 678 int64_t changestamp = 0;
676 EXPECT_EQ(FILE_ERROR_OK, 679 EXPECT_EQ(FILE_ERROR_OK,
677 resource_metadata_->GetLargestChangestamp(&changestamp)); 680 resource_metadata_->GetLargestChangestamp(&changestamp));
678 EXPECT_EQ(0, changestamp); 681 EXPECT_EQ(0, changestamp);
679 682
680 // root should continue to exist. 683 // root should continue to exist.
681 ResourceEntry entry; 684 ResourceEntry entry;
682 ASSERT_EQ(FILE_ERROR_OK, 685 ASSERT_EQ(FILE_ERROR_OK,
683 resource_metadata_->GetResourceEntryByPath( 686 resource_metadata_->GetResourceEntryByPath(
684 base::FilePath::FromUTF8Unsafe("drive"), &entry)); 687 base::FilePath::FromUTF8Unsafe("drive"), &entry));
685 EXPECT_EQ("drive", entry.base_name()); 688 EXPECT_EQ("drive", entry.base_name());
(...skipping 14 matching lines...) Expand all
700 703
701 // The "trash" directory should be empty. 704 // The "trash" directory should be empty.
702 ASSERT_EQ(FILE_ERROR_OK, 705 ASSERT_EQ(FILE_ERROR_OK,
703 resource_metadata_->ReadDirectoryByPath( 706 resource_metadata_->ReadDirectoryByPath(
704 base::FilePath::FromUTF8Unsafe("drive/trash"), &entries)); 707 base::FilePath::FromUTF8Unsafe("drive/trash"), &entries));
705 EXPECT_TRUE(entries.empty()); 708 EXPECT_TRUE(entries.empty());
706 } 709 }
707 710
708 } // namespace internal 711 } // namespace internal
709 } // namespace drive 712 } // namespace drive
OLDNEW
« no previous file with comments | « components/drive/resource_metadata_storage_unittest.cc ('k') | components/drive/search_metadata.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698