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

Side by Side Diff: chrome/browser/google_apis/drive_api_parser_unittest.cc

Issue 18355004: google_apis: Move data files out of chrome/test/data/chromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix extension tests Created 7 years, 5 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
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 "chrome/browser/google_apis/drive_api_parser.h" 5 #include "chrome/browser/google_apis/drive_api_parser.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 9 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
10 #include "chrome/browser/google_apis/test_util.h" 10 #include "chrome/browser/google_apis/test_util.h"
11 #include "chrome/browser/google_apis/time_util.h" 11 #include "chrome/browser/google_apis/time_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace google_apis { 14 namespace google_apis {
15 15
16 // TODO(nhiroki): Make it possible to run these tests on any platforms after 16 // TODO(nhiroki): Make it possible to run these tests on any platforms after
17 // moving json files to out of 'chromeos' directory (http://crbug.com/149788). 17 // moving json files to out of 'chromeos' directory (http://crbug.com/149788).
18 #if defined(OS_CHROMEOS) 18 #if defined(OS_CHROMEOS)
19 // Test about resource parsing. 19 // Test about resource parsing.
20 TEST(DriveAPIParserTest, AboutResourceParser) { 20 TEST(DriveAPIParserTest, AboutResourceParser) {
21 std::string error; 21 std::string error;
22 scoped_ptr<base::Value> document = test_util::LoadJSONFile( 22 scoped_ptr<base::Value> document = test_util::LoadJSONFile(
23 "chromeos/drive/about.json"); 23 "drive/about.json");
24 ASSERT_TRUE(document.get()); 24 ASSERT_TRUE(document.get());
25 25
26 ASSERT_EQ(base::Value::TYPE_DICTIONARY, document->GetType()); 26 ASSERT_EQ(base::Value::TYPE_DICTIONARY, document->GetType());
27 scoped_ptr<AboutResource> resource(new AboutResource()); 27 scoped_ptr<AboutResource> resource(new AboutResource());
28 EXPECT_TRUE(resource->Parse(*document)); 28 EXPECT_TRUE(resource->Parse(*document));
29 29
30 EXPECT_EQ("0AIv7G8yEYAWHUk9123", resource->root_folder_id()); 30 EXPECT_EQ("0AIv7G8yEYAWHUk9123", resource->root_folder_id());
31 EXPECT_EQ(5368709120LL, resource->quota_bytes_total()); 31 EXPECT_EQ(5368709120LL, resource->quota_bytes_total());
32 EXPECT_EQ(1073741824LL, resource->quota_bytes_used()); 32 EXPECT_EQ(1073741824LL, resource->quota_bytes_used());
33 EXPECT_EQ(8177LL, resource->largest_change_id()); 33 EXPECT_EQ(8177LL, resource->largest_change_id());
(...skipping 15 matching lines...) Expand all
49 EXPECT_EQ(10000, about_resource->quota_bytes_total()); 49 EXPECT_EQ(10000, about_resource->quota_bytes_total());
50 EXPECT_EQ(1000, about_resource->quota_bytes_used()); 50 EXPECT_EQ(1000, about_resource->quota_bytes_used());
51 EXPECT_EQ(100, about_resource->largest_change_id()); 51 EXPECT_EQ(100, about_resource->largest_change_id());
52 EXPECT_EQ("dummy_root_id", about_resource->root_folder_id()); 52 EXPECT_EQ("dummy_root_id", about_resource->root_folder_id());
53 } 53 }
54 54
55 // Test app list parsing. 55 // Test app list parsing.
56 TEST(DriveAPIParserTest, AppListParser) { 56 TEST(DriveAPIParserTest, AppListParser) {
57 std::string error; 57 std::string error;
58 scoped_ptr<base::Value> document = test_util::LoadJSONFile( 58 scoped_ptr<base::Value> document = test_util::LoadJSONFile(
59 "chromeos/drive/applist.json"); 59 "drive/applist.json");
60 ASSERT_TRUE(document.get()); 60 ASSERT_TRUE(document.get());
61 61
62 ASSERT_EQ(base::Value::TYPE_DICTIONARY, document->GetType()); 62 ASSERT_EQ(base::Value::TYPE_DICTIONARY, document->GetType());
63 scoped_ptr<AppList> applist(new AppList); 63 scoped_ptr<AppList> applist(new AppList);
64 EXPECT_TRUE(applist->Parse(*document)); 64 EXPECT_TRUE(applist->Parse(*document));
65 65
66 EXPECT_EQ("\"Jm4BaSnCWNND-noZsHINRqj4ABC/tuqRBw0lvjUdPtc_2msA1tN4XYZ\"", 66 EXPECT_EQ("\"Jm4BaSnCWNND-noZsHINRqj4ABC/tuqRBw0lvjUdPtc_2msA1tN4XYZ\"",
67 applist->etag()); 67 applist->etag());
68 ASSERT_EQ(2U, applist->items().size()); 68 ASSERT_EQ(2U, applist->items().size());
69 // Check Drive app 1 69 // Check Drive app 1
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 const DriveAppIcon& icon = *icons[0]; 227 const DriveAppIcon& icon = *icons[0];
228 EXPECT_EQ(DriveAppIcon::DOCUMENT, icon.category()); 228 EXPECT_EQ(DriveAppIcon::DOCUMENT, icon.category());
229 EXPECT_EQ(10, icon.icon_side_length()); 229 EXPECT_EQ(10, icon.icon_side_length());
230 EXPECT_EQ("http://icon/url", icon.icon_url().spec()); 230 EXPECT_EQ("http://icon/url", icon.icon_url().spec());
231 } 231 }
232 232
233 // Test file list parsing. 233 // Test file list parsing.
234 TEST(DriveAPIParserTest, FileListParser) { 234 TEST(DriveAPIParserTest, FileListParser) {
235 std::string error; 235 std::string error;
236 scoped_ptr<base::Value> document = test_util::LoadJSONFile( 236 scoped_ptr<base::Value> document = test_util::LoadJSONFile(
237 "chromeos/drive/filelist.json"); 237 "drive/filelist.json");
238 ASSERT_TRUE(document.get()); 238 ASSERT_TRUE(document.get());
239 239
240 ASSERT_EQ(base::Value::TYPE_DICTIONARY, document->GetType()); 240 ASSERT_EQ(base::Value::TYPE_DICTIONARY, document->GetType());
241 scoped_ptr<FileList> filelist(new FileList); 241 scoped_ptr<FileList> filelist(new FileList);
242 EXPECT_TRUE(filelist->Parse(*document)); 242 EXPECT_TRUE(filelist->Parse(*document));
243 243
244 EXPECT_EQ("\"WtRjAPZWbDA7_fkFjc5ojsEvDEF/zyHTfoHpnRHovyi8bWpwK0DXABC\"", 244 EXPECT_EQ("\"WtRjAPZWbDA7_fkFjc5ojsEvDEF/zyHTfoHpnRHovyi8bWpwK0DXABC\"",
245 filelist->etag()); 245 filelist->etag());
246 EXPECT_EQ("EAIaggELEgA6egpi96It9mH_____f_8AAP__AAD_okhU-cHLz83KzszMxsjMzs_Ry" 246 EXPECT_EQ("EAIaggELEgA6egpi96It9mH_____f_8AAP__AAD_okhU-cHLz83KzszMxsjMzs_Ry"
247 "NGJnridyrbHs7u9tv8AAP__AP7__n__AP8AokhU-cHLz83KzszMxsjMzs_RyNGJnr" 247 "NGJnridyrbHs7u9tv8AAP__AP7__n__AP8AokhU-cHLz83KzszMxsjMzs_RyNGJnr"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 ASSERT_EQ(1U, file3.parents().size()); 343 ASSERT_EQ(1U, file3.parents().size());
344 EXPECT_EQ("0AIv7G8yEYAWHUk9ABC", file3.parents()[0]->file_id()); 344 EXPECT_EQ("0AIv7G8yEYAWHUk9ABC", file3.parents()[0]->file_id());
345 EXPECT_TRUE(file3.parents()[0]->is_root()); 345 EXPECT_TRUE(file3.parents()[0]->is_root());
346 EXPECT_EQ(0U, file3.open_with_links().size()); 346 EXPECT_EQ(0U, file3.open_with_links().size());
347 } 347 }
348 348
349 // Test change list parsing. 349 // Test change list parsing.
350 TEST(DriveAPIParserTest, ChangeListParser) { 350 TEST(DriveAPIParserTest, ChangeListParser) {
351 std::string error; 351 std::string error;
352 scoped_ptr<base::Value> document = 352 scoped_ptr<base::Value> document =
353 test_util::LoadJSONFile("chromeos/drive/changelist.json"); 353 test_util::LoadJSONFile("drive/changelist.json");
354 ASSERT_TRUE(document.get()); 354 ASSERT_TRUE(document.get());
355 355
356 ASSERT_EQ(base::Value::TYPE_DICTIONARY, document->GetType()); 356 ASSERT_EQ(base::Value::TYPE_DICTIONARY, document->GetType());
357 scoped_ptr<ChangeList> changelist(new ChangeList); 357 scoped_ptr<ChangeList> changelist(new ChangeList);
358 EXPECT_TRUE(changelist->Parse(*document)); 358 EXPECT_TRUE(changelist->Parse(*document));
359 359
360 EXPECT_EQ("\"Lp2bjAtLP341hvGmYHhxjYyBPJ8/BWbu_eylt5f_aGtCN6mGRv9hABC\"", 360 EXPECT_EQ("\"Lp2bjAtLP341hvGmYHhxjYyBPJ8/BWbu_eylt5f_aGtCN6mGRv9hABC\"",
361 changelist->etag()); 361 changelist->etag());
362 EXPECT_EQ("8929", changelist->next_page_token()); 362 EXPECT_EQ("8929", changelist->next_page_token());
363 EXPECT_EQ("https://www.googleapis.com/drive/v2/changes?pageToken=8929", 363 EXPECT_EQ("https://www.googleapis.com/drive/v2/changes?pageToken=8929",
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 EXPECT_TRUE(change4.is_deleted()); 406 EXPECT_TRUE(change4.is_deleted());
407 407
408 scoped_ptr<ResourceEntry> entry4( 408 scoped_ptr<ResourceEntry> entry4(
409 ResourceEntry::CreateFromChangeResource(change4)); 409 ResourceEntry::CreateFromChangeResource(change4));
410 EXPECT_EQ(change4.file_id(), entry4->resource_id()); 410 EXPECT_EQ(change4.file_id(), entry4->resource_id());
411 EXPECT_EQ(change4.is_deleted(), entry4->deleted()); 411 EXPECT_EQ(change4.is_deleted(), entry4->deleted());
412 } 412 }
413 413
414 TEST(DriveAPIParserTest, HasKind) { 414 TEST(DriveAPIParserTest, HasKind) {
415 scoped_ptr<base::Value> change_list_json( 415 scoped_ptr<base::Value> change_list_json(
416 test_util::LoadJSONFile("chromeos/drive/changelist.json")); 416 test_util::LoadJSONFile("drive/changelist.json"));
417 scoped_ptr<base::Value> file_list_json( 417 scoped_ptr<base::Value> file_list_json(
418 test_util::LoadJSONFile("chromeos/drive/filelist.json")); 418 test_util::LoadJSONFile("drive/filelist.json"));
419 419
420 EXPECT_TRUE(ChangeList::HasChangeListKind(*change_list_json)); 420 EXPECT_TRUE(ChangeList::HasChangeListKind(*change_list_json));
421 EXPECT_FALSE(ChangeList::HasChangeListKind(*file_list_json)); 421 EXPECT_FALSE(ChangeList::HasChangeListKind(*file_list_json));
422 422
423 EXPECT_FALSE(FileList::HasFileListKind(*change_list_json)); 423 EXPECT_FALSE(FileList::HasFileListKind(*change_list_json));
424 EXPECT_TRUE(FileList::HasFileListKind(*file_list_json)); 424 EXPECT_TRUE(FileList::HasFileListKind(*file_list_json));
425 } 425 }
426 #endif // OS_CHROMEOS 426 #endif // OS_CHROMEOS
427 427
428 } // namespace google_apis 428 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/base_requests_server_unittest.cc ('k') | chrome/browser/google_apis/drive_api_requests_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698