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

Side by Side Diff: chrome/browser/drive/test_util.cc

Issue 439713003: Drop prefixes from test data resource IDs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
« no previous file with comments | « chrome/browser/drive/fake_drive_service_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/drive/test_util.h" 5 #include "chrome/browser/drive/test_util.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "chrome/browser/drive/drive_api_util.h" 8 #include "chrome/browser/drive/drive_api_util.h"
9 #include "chrome/browser/drive/fake_drive_service.h" 9 #include "chrome/browser/drive/fake_drive_service.h"
10 #include "google_apis/drive/drive_api_parser.h" 10 #include "google_apis/drive/drive_api_parser.h"
11 #include "google_apis/drive/test_util.h" 11 #include "google_apis/drive/test_util.h"
12 12
13 using google_apis::FileResource; 13 using google_apis::FileResource;
14 using google_apis::GDATA_OTHER_ERROR; 14 using google_apis::GDATA_OTHER_ERROR;
15 using google_apis::GDataErrorCode; 15 using google_apis::GDataErrorCode;
16 using google_apis::HTTP_CREATED; 16 using google_apis::HTTP_CREATED;
17 17
18 namespace drive { 18 namespace drive {
19 namespace test_util { 19 namespace test_util {
20 20
21 bool SetUpTestEntries(FakeDriveService* drive_service) { 21 bool SetUpTestEntries(FakeDriveService* drive_service) {
22 GDataErrorCode error = GDATA_OTHER_ERROR; 22 GDataErrorCode error = GDATA_OTHER_ERROR;
23 scoped_ptr<FileResource> entry; 23 scoped_ptr<FileResource> entry;
24 24
25 drive_service->AddNewFileWithResourceId( 25 drive_service->AddNewFileWithResourceId(
26 "file:2_file_resource_id", 26 "2_file_resource_id",
27 "audio/mpeg", 27 "audio/mpeg",
28 "This is some test content.", 28 "This is some test content.",
29 drive_service->GetRootResourceId(), 29 drive_service->GetRootResourceId(),
30 "File 1.txt", 30 "File 1.txt",
31 false, // shared_with_me 31 false, // shared_with_me
32 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 32 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
33 base::RunLoop().RunUntilIdle(); 33 base::RunLoop().RunUntilIdle();
34 if (error != HTTP_CREATED) 34 if (error != HTTP_CREATED)
35 return false; 35 return false;
36 36
37 drive_service->AddNewFileWithResourceId( 37 drive_service->AddNewFileWithResourceId(
38 "file:slash_file_resource_id", 38 "slash_file_resource_id",
39 "audio/mpeg", 39 "audio/mpeg",
40 "This is some test content.", 40 "This is some test content.",
41 drive_service->GetRootResourceId(), 41 drive_service->GetRootResourceId(),
42 "Slash / in file 1.txt", 42 "Slash / in file 1.txt",
43 false, // shared_with_me 43 false, // shared_with_me
44 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 44 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
45 base::RunLoop().RunUntilIdle(); 45 base::RunLoop().RunUntilIdle();
46 if (error != HTTP_CREATED) 46 if (error != HTTP_CREATED)
47 return false; 47 return false;
48 48
49 drive_service->AddNewFileWithResourceId( 49 drive_service->AddNewFileWithResourceId(
50 "file:3_file_resource_id", 50 "3_file_resource_id",
51 "audio/mpeg", 51 "audio/mpeg",
52 "This is some test content.", 52 "This is some test content.",
53 drive_service->GetRootResourceId(), 53 drive_service->GetRootResourceId(),
54 "Duplicate Name.txt", 54 "Duplicate Name.txt",
55 false, // shared_with_me 55 false, // shared_with_me
56 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 56 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
57 base::RunLoop().RunUntilIdle(); 57 base::RunLoop().RunUntilIdle();
58 if (error != HTTP_CREATED) 58 if (error != HTTP_CREATED)
59 return false; 59 return false;
60 60
61 drive_service->AddNewFileWithResourceId( 61 drive_service->AddNewFileWithResourceId(
62 "file:4_file_resource_id", 62 "4_file_resource_id",
63 "audio/mpeg", 63 "audio/mpeg",
64 "This is some test content.", 64 "This is some test content.",
65 drive_service->GetRootResourceId(), 65 drive_service->GetRootResourceId(),
66 "Duplicate Name.txt", 66 "Duplicate Name.txt",
67 false, // shared_with_me 67 false, // shared_with_me
68 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 68 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
69 base::RunLoop().RunUntilIdle(); 69 base::RunLoop().RunUntilIdle();
70 if (error != HTTP_CREATED) 70 if (error != HTTP_CREATED)
71 return false; 71 return false;
72 72
73 drive_service->AddNewFileWithResourceId( 73 drive_service->AddNewFileWithResourceId(
74 "document:5_document_resource_id", 74 "5_document_resource_id",
75 util::kGoogleDocumentMimeType, 75 util::kGoogleDocumentMimeType,
76 std::string(), 76 std::string(),
77 drive_service->GetRootResourceId(), 77 drive_service->GetRootResourceId(),
78 "Document 1 excludeDir-test", 78 "Document 1 excludeDir-test",
79 false, // shared_with_me 79 false, // shared_with_me
80 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 80 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
81 base::RunLoop().RunUntilIdle(); 81 base::RunLoop().RunUntilIdle();
82 if (error != HTTP_CREATED) 82 if (error != HTTP_CREATED)
83 return false; 83 return false;
84 84
85 drive_service->AddNewFileWithResourceId( 85 drive_service->AddNewFileWithResourceId(
86 "folder:1_folder_resource_id", 86 "1_folder_resource_id",
87 util::kDriveFolderMimeType, 87 util::kDriveFolderMimeType,
88 std::string(), 88 std::string(),
89 drive_service->GetRootResourceId(), 89 drive_service->GetRootResourceId(),
90 "Directory 1", 90 "Directory 1",
91 false, // shared_with_me 91 false, // shared_with_me
92 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 92 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
93 base::RunLoop().RunUntilIdle(); 93 base::RunLoop().RunUntilIdle();
94 if (error != HTTP_CREATED) 94 if (error != HTTP_CREATED)
95 return false; 95 return false;
96 96
97 drive_service->AddNewFileWithResourceId( 97 drive_service->AddNewFileWithResourceId(
98 "file:subdirectory_file_1_id", 98 "subdirectory_file_1_id",
99 "audio/mpeg", 99 "audio/mpeg",
100 "This is some test content.", 100 "This is some test content.",
101 "folder:1_folder_resource_id", 101 "1_folder_resource_id",
102 "SubDirectory File 1.txt", 102 "SubDirectory File 1.txt",
103 false, // shared_with_me 103 false, // shared_with_me
104 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 104 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
105 base::RunLoop().RunUntilIdle(); 105 base::RunLoop().RunUntilIdle();
106 if (error != HTTP_CREATED) 106 if (error != HTTP_CREATED)
107 return false; 107 return false;
108 108
109 drive_service->AddNewFileWithResourceId( 109 drive_service->AddNewFileWithResourceId(
110 "file:subdirectory_unowned_file_1_id", 110 "subdirectory_unowned_file_1_id",
111 "audio/mpeg", 111 "audio/mpeg",
112 "This is some test content.", 112 "This is some test content.",
113 "folder:1_folder_resource_id", 113 "1_folder_resource_id",
114 "Shared to The Account Owner.txt", 114 "Shared to The Account Owner.txt",
115 true, // shared_with_me 115 true, // shared_with_me
116 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 116 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
117 base::RunLoop().RunUntilIdle(); 117 base::RunLoop().RunUntilIdle();
118 if (error != HTTP_CREATED) 118 if (error != HTTP_CREATED)
119 return false; 119 return false;
120 120
121 drive_service->AddNewDirectoryWithResourceId( 121 drive_service->AddNewDirectoryWithResourceId(
122 "folder:sub_dir_folder_resource_id", 122 "sub_dir_folder_resource_id",
123 "folder:1_folder_resource_id", 123 "1_folder_resource_id",
124 "Sub Directory Folder", 124 "Sub Directory Folder",
125 DriveServiceInterface::AddNewDirectoryOptions(), 125 DriveServiceInterface::AddNewDirectoryOptions(),
126 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 126 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
127 base::RunLoop().RunUntilIdle(); 127 base::RunLoop().RunUntilIdle();
128 if (error != HTTP_CREATED) 128 if (error != HTTP_CREATED)
129 return false; 129 return false;
130 130
131 drive_service->AddNewDirectoryWithResourceId( 131 drive_service->AddNewDirectoryWithResourceId(
132 "folder:sub_sub_directory_folder_id", 132 "sub_sub_directory_folder_id",
133 "folder:sub_dir_folder_resource_id", 133 "sub_dir_folder_resource_id",
134 "Sub Sub Directory Folder", 134 "Sub Sub Directory Folder",
135 DriveServiceInterface::AddNewDirectoryOptions(), 135 DriveServiceInterface::AddNewDirectoryOptions(),
136 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 136 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
137 base::RunLoop().RunUntilIdle(); 137 base::RunLoop().RunUntilIdle();
138 if (error != HTTP_CREATED) 138 if (error != HTTP_CREATED)
139 return false; 139 return false;
140 140
141 drive_service->AddNewDirectoryWithResourceId( 141 drive_service->AddNewDirectoryWithResourceId(
142 "folder:slash_dir_folder_resource_id", 142 "slash_dir_folder_resource_id",
143 drive_service->GetRootResourceId(), 143 drive_service->GetRootResourceId(),
144 "Slash / in directory", 144 "Slash / in directory",
145 DriveServiceInterface::AddNewDirectoryOptions(), 145 DriveServiceInterface::AddNewDirectoryOptions(),
146 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 146 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
147 base::RunLoop().RunUntilIdle(); 147 base::RunLoop().RunUntilIdle();
148 if (error != HTTP_CREATED) 148 if (error != HTTP_CREATED)
149 return false; 149 return false;
150 150
151 drive_service->AddNewFileWithResourceId( 151 drive_service->AddNewFileWithResourceId(
152 "file:slash_subdir_file", 152 "slash_subdir_file",
153 "audio/mpeg", 153 "audio/mpeg",
154 "This is some test content.", 154 "This is some test content.",
155 "folder:slash_dir_folder_resource_id", 155 "slash_dir_folder_resource_id",
156 "Slash SubDir File.txt", 156 "Slash SubDir File.txt",
157 false, // shared_with_me 157 false, // shared_with_me
158 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 158 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
159 base::RunLoop().RunUntilIdle(); 159 base::RunLoop().RunUntilIdle();
160 if (error != HTTP_CREATED) 160 if (error != HTTP_CREATED)
161 return false; 161 return false;
162 162
163 drive_service->AddNewDirectoryWithResourceId( 163 drive_service->AddNewDirectoryWithResourceId(
164 "folder:sub_dir_folder_2_self_link", 164 "sub_dir_folder_2_self_link",
165 drive_service->GetRootResourceId(), 165 drive_service->GetRootResourceId(),
166 "Directory 2 excludeDir-test", 166 "Directory 2 excludeDir-test",
167 DriveServiceInterface::AddNewDirectoryOptions(), 167 DriveServiceInterface::AddNewDirectoryOptions(),
168 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 168 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
169 base::RunLoop().RunUntilIdle(); 169 base::RunLoop().RunUntilIdle();
170 if (error != HTTP_CREATED) 170 if (error != HTTP_CREATED)
171 return false; 171 return false;
172 172
173 drive_service->AddNewFileWithResourceId( 173 drive_service->AddNewFileWithResourceId(
174 "file:1_orphanfile_resource_id", 174 "1_orphanfile_resource_id",
175 "text/plain", 175 "text/plain",
176 "This is some test content.", 176 "This is some test content.",
177 std::string(), 177 std::string(),
178 "Orphan File 1.txt", 178 "Orphan File 1.txt",
179 true, // shared_with_me 179 true, // shared_with_me
180 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 180 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
181 base::RunLoop().RunUntilIdle(); 181 base::RunLoop().RunUntilIdle();
182 if (error != HTTP_CREATED) 182 if (error != HTTP_CREATED)
183 return false; 183 return false;
184 184
185 drive_service->AddNewFileWithResourceId( 185 drive_service->AddNewFileWithResourceId(
186 "document:orphan_doc_1", 186 "orphan_doc_1",
187 util::kGoogleDocumentMimeType, 187 util::kGoogleDocumentMimeType,
188 std::string(), 188 std::string(),
189 std::string(), 189 std::string(),
190 "Orphan Document", 190 "Orphan Document",
191 true, // shared_with_me 191 true, // shared_with_me
192 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 192 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
193 base::RunLoop().RunUntilIdle(); 193 base::RunLoop().RunUntilIdle();
194 if (error != HTTP_CREATED) 194 if (error != HTTP_CREATED)
195 return false; 195 return false;
196 196
197 return true; 197 return true;
198 } 198 }
199 199
200 } // namespace test_util 200 } // namespace test_util
201 } // namespace drive 201 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/drive/fake_drive_service_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698