• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "chrome/browser/chromeos/drive/file_change.h"
6 
7 #include "testing/gtest/include/gtest/gtest.h"
8 
9 namespace drive {
10 
TEST(ChangeListTest,FileChange_Change)11 TEST(ChangeListTest, FileChange_Change) {
12   FileChange::ChangeType change_type = FileChange::ADD_OR_UPDATE;
13   FileChange::FileType file_type = FileChange::FILE_TYPE_FILE;
14 
15   FileChange::Change change1(change_type, file_type);
16   EXPECT_EQ(change_type, change1.change());
17   EXPECT_EQ(file_type, change1.file_type());
18 
19   FileChange::Change change2(change_type, file_type);
20   EXPECT_EQ(change_type, change1.change());
21   EXPECT_EQ(file_type, change1.file_type());
22   EXPECT_EQ(change1, change2);
23 
24   FileChange::Change change3(change_type, FileChange::FILE_TYPE_DIRECTORY);
25   EXPECT_EQ(change_type, change3.change());
26   EXPECT_EQ(FileChange::FILE_TYPE_DIRECTORY, change3.file_type());
27   EXPECT_TRUE(!(change1 == change3));
28 }
29 
TEST(ChangeListTest,FileChangeChangeList)30 TEST(ChangeListTest, FileChangeChangeList) {
31   FileChange::ChangeList changes;
32   EXPECT_TRUE(changes.empty());
33   EXPECT_EQ(0u, changes.size());
34 
35   changes.Update(FileChange::Change(FileChange::ADD_OR_UPDATE,
36                                     FileChange::FILE_TYPE_FILE));
37   EXPECT_EQ(1u, changes.size());
38 }
39 
TEST(ChangeListTest,FileChange)40 TEST(ChangeListTest, FileChange) {
41   base::FilePath change_path1(FILE_PATH_LITERAL("test"));
42   base::FilePath change_path2(FILE_PATH_LITERAL("a/b/c/d"));
43   base::FilePath change_path3(FILE_PATH_LITERAL("a/b/c/e"));
44   base::FilePath change_dir(FILE_PATH_LITERAL("a/b/c"));
45 
46   FileChange changed_files;
47   changed_files.Update(
48       change_path1, FileChange::FILE_TYPE_FILE, FileChange::ADD_OR_UPDATE);
49   changed_files.Update(
50       change_path2, FileChange::FILE_TYPE_FILE, FileChange::ADD_OR_UPDATE);
51   changed_files.Update(
52       change_path2, FileChange::FILE_TYPE_FILE, FileChange::ADD_OR_UPDATE);
53   changed_files.Update(
54       change_path3, FileChange::FILE_TYPE_FILE, FileChange::ADD_OR_UPDATE);
55 
56   ASSERT_EQ(3u, changed_files.size());
57   ASSERT_EQ(2u, changed_files.CountDirectory(change_dir));
58 }
59 
60 }  // namespace drive
61