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

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

Issue 11293005: Move chrome/test/data/chromeos/gdata to chrome/test/data/gdata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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/gdata_wapi_parser.h" 5 #include "chrome/browser/google_apis/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/logging.h" 10 #include "base/logging.h"
(...skipping 10 matching lines...) Expand all
21 21
22 using base::Value; 22 using base::Value;
23 using base::DictionaryValue; 23 using base::DictionaryValue;
24 using base::ListValue; 24 using base::ListValue;
25 25
26 namespace google_apis { 26 namespace google_apis {
27 27
28 class GDataWAPIParserTest : public testing::Test { 28 class GDataWAPIParserTest : public testing::Test {
29 protected: 29 protected:
30 static DocumentEntry* LoadDocumentEntryFromXml(const std::string& filename) { 30 static DocumentEntry* LoadDocumentEntryFromXml(const std::string& filename) {
31 FilePath path; 31 FilePath path = test_util::GetTestFilePath(filename);
32 std::string error; 32 std::string error;
33 PathService::Get(chrome::DIR_TEST_DATA, &path);
34 path = path.AppendASCII("chromeos")
35 .AppendASCII("gdata")
36 .AppendASCII(filename.c_str());
37 EXPECT_TRUE(file_util::PathExists(path)) << 33 EXPECT_TRUE(file_util::PathExists(path)) <<
38 "Couldn't find " << path.value(); 34 "Couldn't find " << path.value();
39 std::string contents; 35 std::string contents;
40 EXPECT_TRUE(file_util::ReadFileToString(path, &contents)); 36 EXPECT_TRUE(file_util::ReadFileToString(path, &contents));
41 XmlReader reader; 37 XmlReader reader;
42 if (!reader.Load(contents)) { 38 if (!reader.Load(contents)) {
43 NOTREACHED() << "Invalid xml:\n" << contents; 39 NOTREACHED() << "Invalid xml:\n" << contents;
44 return NULL; 40 return NULL;
45 } 41 }
46 scoped_ptr<DocumentEntry> entry; 42 scoped_ptr<DocumentEntry> entry;
47 while (reader.Read()) { 43 while (reader.Read()) {
48 if (reader.NodeName() == "entry") { 44 if (reader.NodeName() == "entry") {
49 entry.reset(DocumentEntry::CreateFromXml(&reader)); 45 entry.reset(DocumentEntry::CreateFromXml(&reader));
50 break; 46 break;
51 } 47 }
52 } 48 }
53 return entry.release(); 49 return entry.release();
54 } 50 }
55 }; 51 };
56 52
57 // TODO(nhiroki): Make it possible to run these tests on any platforms after
58 // moving json files to out of 'chromeos' directory (http://crbug.com/149788).
59 #if defined(OS_CHROMEOS)
60 // Test document feed parsing. 53 // Test document feed parsing.
61 TEST_F(GDataWAPIParserTest, DocumentFeedJsonParser) { 54 TEST_F(GDataWAPIParserTest, DocumentFeedJsonParser) {
62 std::string error; 55 std::string error;
63 scoped_ptr<Value> document = 56 scoped_ptr<Value> document =
64 test_util::LoadJSONFile("gdata/basic_feed.json"); 57 test_util::LoadJSONFile("gdata/basic_feed.json");
65 ASSERT_TRUE(document.get()); 58 ASSERT_TRUE(document.get());
66 ASSERT_EQ(Value::TYPE_DICTIONARY, document->GetType()); 59 ASSERT_EQ(Value::TYPE_DICTIONARY, document->GetType());
67 scoped_ptr<DocumentFeed> feed(DocumentFeed::ExtractAndParse(*document)); 60 scoped_ptr<DocumentFeed> feed(DocumentFeed::ExtractAndParse(*document));
68 ASSERT_TRUE(feed.get()); 61 ASSERT_TRUE(feed.get());
69 62
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 ASSERT_TRUE(app_entry); 175 ASSERT_TRUE(app_entry);
183 EXPECT_EQ(ENTRY_KIND_EXTERNAL_APP, app_entry->kind()); 176 EXPECT_EQ(ENTRY_KIND_EXTERNAL_APP, app_entry->kind());
184 EXPECT_TRUE(app_entry->is_hosted_document()); 177 EXPECT_TRUE(app_entry->is_hosted_document());
185 EXPECT_TRUE(app_entry->is_external_document()); 178 EXPECT_TRUE(app_entry->is_external_document());
186 EXPECT_FALSE(app_entry->is_google_document()); 179 EXPECT_FALSE(app_entry->is_google_document());
187 } 180 }
188 181
189 182
190 // Test document feed parsing. 183 // Test document feed parsing.
191 TEST_F(GDataWAPIParserTest, DocumentEntryXmlParser) { 184 TEST_F(GDataWAPIParserTest, DocumentEntryXmlParser) {
192 scoped_ptr<DocumentEntry> entry(LoadDocumentEntryFromXml("entry.xml")); 185 scoped_ptr<DocumentEntry> entry(LoadDocumentEntryFromXml("gdata/entry.xml"));
193 ASSERT_TRUE(entry.get()); 186 ASSERT_TRUE(entry.get());
194 187
195 EXPECT_EQ(ENTRY_KIND_FILE, entry->kind()); 188 EXPECT_EQ(ENTRY_KIND_FILE, entry->kind());
196 EXPECT_EQ("\"HhMOFgcNHSt7ImBr\"", entry->etag()); 189 EXPECT_EQ("\"HhMOFgcNHSt7ImBr\"", entry->etag());
197 EXPECT_EQ("file:xml_file_resource_id", entry->resource_id()); 190 EXPECT_EQ("file:xml_file_resource_id", entry->resource_id());
198 EXPECT_EQ("https://xml_file_id", entry->id()); 191 EXPECT_EQ("https://xml_file_id", entry->id());
199 EXPECT_EQ(ASCIIToUTF16("Xml Entry File Title.tar"), entry->title()); 192 EXPECT_EQ(ASCIIToUTF16("Xml Entry File Title.tar"), entry->title());
200 base::Time entry1_update_time; 193 base::Time entry1_update_time;
201 base::Time entry1_publish_time; 194 base::Time entry1_publish_time;
202 ASSERT_TRUE(google_apis::util::GetTimeFromString("2011-04-01T18:34:08.234Z", 195 ASSERT_TRUE(google_apis::util::GetTimeFromString("2011-04-01T18:34:08.234Z",
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 EXPECT_EQ("Drive App 2", UTF16ToUTF8(second_app->app_name())); 322 EXPECT_EQ("Drive App 2", UTF16ToUTF8(second_app->app_name()));
330 EXPECT_EQ("Drive App Object 2", UTF16ToUTF8(second_app->object_type())); 323 EXPECT_EQ("Drive App Object 2", UTF16ToUTF8(second_app->object_type()));
331 EXPECT_EQ("https://chrome.google.com/webstore/detail/deadbeefdeadbeef", 324 EXPECT_EQ("https://chrome.google.com/webstore/detail/deadbeefdeadbeef",
332 second_app->GetProductUrl().spec()); 325 second_app->GetProductUrl().spec());
333 EXPECT_FALSE(second_app->supports_create()); 326 EXPECT_FALSE(second_app->supports_create());
334 EXPECT_EQ(2U, second_app->primary_mimetypes().size()); 327 EXPECT_EQ(2U, second_app->primary_mimetypes().size());
335 EXPECT_EQ(0U, second_app->secondary_mimetypes().size()); 328 EXPECT_EQ(0U, second_app->secondary_mimetypes().size());
336 EXPECT_EQ(1U, second_app->primary_extensions().size()); 329 EXPECT_EQ(1U, second_app->primary_extensions().size());
337 EXPECT_EQ(0U, second_app->secondary_extensions().size()); 330 EXPECT_EQ(0U, second_app->secondary_extensions().size());
338 } 331 }
339 #endif // OS_CHROMEOS
340 332
341 // Test file extension checking in DocumentEntry::HasDocumentExtension(). 333 // Test file extension checking in DocumentEntry::HasDocumentExtension().
342 TEST_F(GDataWAPIParserTest, DocumentEntryHasDocumentExtension) { 334 TEST_F(GDataWAPIParserTest, DocumentEntryHasDocumentExtension) {
343 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( 335 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension(
344 FilePath(FILE_PATH_LITERAL("Test.gdoc")))); 336 FilePath(FILE_PATH_LITERAL("Test.gdoc"))));
345 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( 337 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension(
346 FilePath(FILE_PATH_LITERAL("Test.gsheet")))); 338 FilePath(FILE_PATH_LITERAL("Test.gsheet"))));
347 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( 339 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension(
348 FilePath(FILE_PATH_LITERAL("Test.gslides")))); 340 FilePath(FILE_PATH_LITERAL("Test.gslides"))));
349 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( 341 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_EXTERNAL_APP)); 379 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_EXTERNAL_APP));
388 EXPECT_EQ(DocumentEntry::KIND_OF_FOLDER, 380 EXPECT_EQ(DocumentEntry::KIND_OF_FOLDER,
389 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_FOLDER)); 381 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_FOLDER));
390 EXPECT_EQ(DocumentEntry::KIND_OF_FILE, 382 EXPECT_EQ(DocumentEntry::KIND_OF_FILE,
391 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_FILE)); 383 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_FILE));
392 EXPECT_EQ(DocumentEntry::KIND_OF_FILE, 384 EXPECT_EQ(DocumentEntry::KIND_OF_FILE,
393 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_PDF)); 385 DocumentEntry::ClassifyEntryKind(ENTRY_KIND_PDF));
394 } 386 }
395 387
396 } // namespace google_apis 388 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/gdata_test_util.cc ('k') | chrome/browser/google_apis/gdata_wapi_service_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698