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

Side by Side Diff: webkit/fileapi/syncable/local_file_sync_status_unittest.cc

Issue 15806012: Move webkit/fileapi/syncable/* code to webkit/browser/fileapi (final!) (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
(Empty)
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 "webkit/fileapi/syncable/local_file_sync_status.h"
6
7 #include "base/basictypes.h"
8 #include "googleurl/src/gurl.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 using fileapi::FileSystemURL;
12
13 namespace sync_file_system {
14
15 namespace {
16
17 const char kParent[] = "filesystem:http://foo.com/test/dir a";
18 const char kFile[] = "filesystem:http://foo.com/test/dir a/dir b";
19 const char kChild[] = "filesystem:http://foo.com/test/dir a/dir b/file";
20
21 const char kOther1[] = "filesystem:http://foo.com/test/dir b";
22 const char kOther2[] = "filesystem:http://foo.com/temporary/dir a";
23
24 FileSystemURL URL(const char* spec) {
25 return FileSystemURL::CreateForTest((GURL(spec)));
26 }
27
28 } // namespace
29
30 TEST(LocalFileSyncStatusTest, WritingSimple) {
31 LocalFileSyncStatus status;
32
33 status.StartWriting(URL(kFile));
34 status.StartWriting(URL(kFile));
35 status.EndWriting(URL(kFile));
36
37 EXPECT_TRUE(status.IsWriting(URL(kFile)));
38 EXPECT_TRUE(status.IsWriting(URL(kParent)));
39 EXPECT_TRUE(status.IsWriting(URL(kChild)));
40 EXPECT_FALSE(status.IsWriting(URL(kOther1)));
41 EXPECT_FALSE(status.IsWriting(URL(kOther2)));
42
43 // Adding writers doesn't change the entry's writability.
44 EXPECT_TRUE(status.IsWritable(URL(kFile)));
45 EXPECT_TRUE(status.IsWritable(URL(kParent)));
46 EXPECT_TRUE(status.IsWritable(URL(kChild)));
47 EXPECT_TRUE(status.IsWritable(URL(kOther1)));
48 EXPECT_TRUE(status.IsWritable(URL(kOther2)));
49
50 // Adding writers makes the entry non-syncable.
51 EXPECT_FALSE(status.IsSyncable(URL(kFile)));
52 EXPECT_FALSE(status.IsSyncable(URL(kParent)));
53 EXPECT_FALSE(status.IsSyncable(URL(kChild)));
54 EXPECT_TRUE(status.IsSyncable(URL(kOther1)));
55 EXPECT_TRUE(status.IsSyncable(URL(kOther2)));
56
57 status.EndWriting(URL(kFile));
58
59 EXPECT_FALSE(status.IsWriting(URL(kFile)));
60 EXPECT_FALSE(status.IsWriting(URL(kParent)));
61 EXPECT_FALSE(status.IsWriting(URL(kChild)));
62 }
63
64 TEST(LocalFileSyncStatusTest, SyncingSimple) {
65 LocalFileSyncStatus status;
66
67 status.StartSyncing(URL(kFile));
68
69 EXPECT_FALSE(status.IsWritable(URL(kFile)));
70 EXPECT_FALSE(status.IsWritable(URL(kParent)));
71 EXPECT_FALSE(status.IsWritable(URL(kChild)));
72 EXPECT_TRUE(status.IsWritable(URL(kOther1)));
73 EXPECT_TRUE(status.IsWritable(URL(kOther2)));
74
75 // New sync cannot be started for entries that are already in syncing.
76 EXPECT_FALSE(status.IsSyncable(URL(kFile)));
77 EXPECT_FALSE(status.IsSyncable(URL(kParent)));
78 EXPECT_FALSE(status.IsSyncable(URL(kChild)));
79 EXPECT_TRUE(status.IsSyncable(URL(kOther1)));
80 EXPECT_TRUE(status.IsSyncable(URL(kOther2)));
81
82 status.EndSyncing(URL(kFile));
83
84 EXPECT_TRUE(status.IsWritable(URL(kFile)));
85 EXPECT_TRUE(status.IsWritable(URL(kParent)));
86 EXPECT_TRUE(status.IsWritable(URL(kChild)));
87 }
88
89 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « webkit/fileapi/syncable/local_file_sync_status.cc ('k') | webkit/fileapi/syncable/local_origin_change_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698