| OLD | NEW |
| 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/chromeos/gdata/gdata_wapi_parser.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 while (reader.Read()) { | 46 while (reader.Read()) { |
| 47 if (reader.NodeName() == "entry") { | 47 if (reader.NodeName() == "entry") { |
| 48 entry.reset(DocumentEntry::CreateFromXml(&reader)); | 48 entry.reset(DocumentEntry::CreateFromXml(&reader)); |
| 49 break; | 49 break; |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 return entry.release(); | 52 return entry.release(); |
| 53 } | 53 } |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // TODO(nhiroki): Make it possible to run these tests on any platforms after |
| 57 // moving json files to out of 'chromeos' directory (http://crbug.com/149788). |
| 58 #if defined(OS_CHROMEOS) |
| 56 // Test document feed parsing. | 59 // Test document feed parsing. |
| 57 TEST_F(GDataWAPIParserTest, DocumentFeedJsonParser) { | 60 TEST_F(GDataWAPIParserTest, DocumentFeedJsonParser) { |
| 58 std::string error; | 61 std::string error; |
| 59 scoped_ptr<Value> document = | 62 scoped_ptr<Value> document = |
| 60 test_util::LoadJSONFile("gdata/basic_feed.json"); | 63 test_util::LoadJSONFile("gdata/basic_feed.json"); |
| 61 ASSERT_TRUE(document.get()); | 64 ASSERT_TRUE(document.get()); |
| 62 ASSERT_EQ(Value::TYPE_DICTIONARY, document->GetType()); | 65 ASSERT_EQ(Value::TYPE_DICTIONARY, document->GetType()); |
| 63 scoped_ptr<DocumentFeed> feed(DocumentFeed::ExtractAndParse(*document)); | 66 scoped_ptr<DocumentFeed> feed(DocumentFeed::ExtractAndParse(*document)); |
| 64 ASSERT_TRUE(feed.get()); | 67 ASSERT_TRUE(feed.get()); |
| 65 | 68 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 EXPECT_EQ("Drive App 2", UTF16ToUTF8(second_app->app_name())); | 328 EXPECT_EQ("Drive App 2", UTF16ToUTF8(second_app->app_name())); |
| 326 EXPECT_EQ("Drive App Object 2", UTF16ToUTF8(second_app->object_type())); | 329 EXPECT_EQ("Drive App Object 2", UTF16ToUTF8(second_app->object_type())); |
| 327 EXPECT_EQ("https://chrome.google.com/webstore/detail/deadbeefdeadbeef", | 330 EXPECT_EQ("https://chrome.google.com/webstore/detail/deadbeefdeadbeef", |
| 328 second_app->GetProductUrl().spec()); | 331 second_app->GetProductUrl().spec()); |
| 329 EXPECT_FALSE(second_app->supports_create()); | 332 EXPECT_FALSE(second_app->supports_create()); |
| 330 EXPECT_EQ(2U, second_app->primary_mimetypes().size()); | 333 EXPECT_EQ(2U, second_app->primary_mimetypes().size()); |
| 331 EXPECT_EQ(0U, second_app->secondary_mimetypes().size()); | 334 EXPECT_EQ(0U, second_app->secondary_mimetypes().size()); |
| 332 EXPECT_EQ(1U, second_app->primary_extensions().size()); | 335 EXPECT_EQ(1U, second_app->primary_extensions().size()); |
| 333 EXPECT_EQ(0U, second_app->secondary_extensions().size()); | 336 EXPECT_EQ(0U, second_app->secondary_extensions().size()); |
| 334 } | 337 } |
| 338 #endif // OS_CHROMEOS |
| 335 | 339 |
| 336 // Test file extension checking in DocumentEntry::HasDocumentExtension(). | 340 // Test file extension checking in DocumentEntry::HasDocumentExtension(). |
| 337 TEST_F(GDataWAPIParserTest, DocumentEntryHasDocumentExtension) { | 341 TEST_F(GDataWAPIParserTest, DocumentEntryHasDocumentExtension) { |
| 338 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( | 342 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( |
| 339 FilePath(FILE_PATH_LITERAL("Test.gdoc")))); | 343 FilePath(FILE_PATH_LITERAL("Test.gdoc")))); |
| 340 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( | 344 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( |
| 341 FilePath(FILE_PATH_LITERAL("Test.gsheet")))); | 345 FilePath(FILE_PATH_LITERAL("Test.gsheet")))); |
| 342 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( | 346 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( |
| 343 FilePath(FILE_PATH_LITERAL("Test.gslides")))); | 347 FilePath(FILE_PATH_LITERAL("Test.gslides")))); |
| 344 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( | 348 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_EXTERNAL_APP)); | 386 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_EXTERNAL_APP)); |
| 383 EXPECT_EQ(DocumentEntry::KIND_OF_FOLDER, | 387 EXPECT_EQ(DocumentEntry::KIND_OF_FOLDER, |
| 384 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_FOLDER)); | 388 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_FOLDER)); |
| 385 EXPECT_EQ(DocumentEntry::KIND_OF_FILE, | 389 EXPECT_EQ(DocumentEntry::KIND_OF_FILE, |
| 386 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_FILE)); | 390 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_FILE)); |
| 387 EXPECT_EQ(DocumentEntry::KIND_OF_FILE, | 391 EXPECT_EQ(DocumentEntry::KIND_OF_FILE, |
| 388 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_PDF)); | 392 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_PDF)); |
| 389 } | 393 } |
| 390 | 394 |
| 391 } // namespace gdata | 395 } // namespace gdata |
| OLD | NEW |