Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / chromeos / drive / file_change_unittest.cc
blobb4372c1ce14e1ebd3bfbfa404c51ea59822b8f67
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.
5 #include "chrome/browser/chromeos/drive/file_change.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace drive {
11 TEST(ChangeListTest, FileChange_Change) {
12 FileChange::ChangeType change_type = FileChange::ADD_OR_UPDATE;
13 FileChange::FileType file_type = FileChange::FILE_TYPE_FILE;
15 FileChange::Change change1(change_type, file_type);
16 EXPECT_EQ(change_type, change1.change());
17 EXPECT_EQ(file_type, change1.file_type());
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);
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));
30 TEST(ChangeListTest, FileChangeChangeList) {
31 FileChange::ChangeList changes;
32 EXPECT_TRUE(changes.empty());
33 EXPECT_EQ(0u, changes.size());
35 changes.Update(FileChange::Change(FileChange::ADD_OR_UPDATE,
36 FileChange::FILE_TYPE_FILE));
37 EXPECT_EQ(1u, changes.size());
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"));
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);
56 ASSERT_EQ(3u, changed_files.size());
57 ASSERT_EQ(2u, changed_files.CountDirectory(change_dir));
60 } // namespace drive