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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
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_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" | 10 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // Do not verify the not found message. | 105 // Do not verify the not found message. |
106 } | 106 } |
107 | 107 |
108 IN_PROC_BROWSER_TEST_F(GDataTest, GetDocuments) { | 108 IN_PROC_BROWSER_TEST_F(GDataTest, GetDocuments) { |
109 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; | 109 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; |
110 base::Value* result_data = NULL; | 110 base::Value* result_data = NULL; |
111 service_->GetDocuments( | 111 service_->GetDocuments( |
112 gdata_test_server_.GetURL("files/chromeos/gdata/root_feed.json"), | 112 gdata_test_server_.GetURL("files/chromeos/gdata/root_feed.json"), |
113 0, // start_changestamp | 113 0, // start_changestamp |
114 std::string(), // search string | 114 std::string(), // search string |
| 115 std::string(), // directory resource ID |
115 base::Bind(&TestGetDocumentsCallback, &result, &result_data)); | 116 base::Bind(&TestGetDocumentsCallback, &result, &result_data)); |
116 ui_test_utils::RunMessageLoop(); | 117 ui_test_utils::RunMessageLoop(); |
117 | 118 |
118 EXPECT_EQ(gdata::HTTP_SUCCESS, result); | 119 EXPECT_EQ(gdata::HTTP_SUCCESS, result); |
119 ASSERT_TRUE(result_data); | 120 ASSERT_TRUE(result_data); |
120 FilePath expected_filepath = gdata_test_server_.document_root().Append( | 121 FilePath expected_filepath = gdata_test_server_.document_root().Append( |
121 FilePath(FILE_PATH_LITERAL("chromeos/gdata/root_feed.json"))); | 122 FilePath(FILE_PATH_LITERAL("chromeos/gdata/root_feed.json"))); |
122 std::string expected_contents; | 123 std::string expected_contents; |
123 file_util::ReadFileToString(expected_filepath, &expected_contents); | 124 file_util::ReadFileToString(expected_filepath, &expected_contents); |
124 scoped_ptr<base::Value> expected_data( | 125 scoped_ptr<base::Value> expected_data( |
125 base::JSONReader::Read(expected_contents)); | 126 base::JSONReader::Read(expected_contents)); |
126 EXPECT_TRUE(base::Value::Equals(expected_data.get(), result_data)); | 127 EXPECT_TRUE(base::Value::Equals(expected_data.get(), result_data)); |
127 delete result_data; | 128 delete result_data; |
128 } | 129 } |
129 | 130 |
130 IN_PROC_BROWSER_TEST_F(GDataTest, GetDocumentsFailure) { | 131 IN_PROC_BROWSER_TEST_F(GDataTest, GetDocumentsFailure) { |
131 // testfile.txt exists but the response is not JSON, so it should | 132 // testfile.txt exists but the response is not JSON, so it should |
132 // emit a parse error instead. | 133 // emit a parse error instead. |
133 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; | 134 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; |
134 base::Value* result_data = NULL; | 135 base::Value* result_data = NULL; |
135 service_->GetDocuments( | 136 service_->GetDocuments( |
136 gdata_test_server_.GetURL("files/chromeos/gdata/testfile.txt"), | 137 gdata_test_server_.GetURL("files/chromeos/gdata/testfile.txt"), |
137 0, // start_changestamp | 138 0, // start_changestamp |
138 std::string(), // search string | 139 std::string(), // search string |
| 140 std::string(), // directory resource ID |
139 base::Bind(&TestGetDocumentsCallback, &result, &result_data)); | 141 base::Bind(&TestGetDocumentsCallback, &result, &result_data)); |
140 ui_test_utils::RunMessageLoop(); | 142 ui_test_utils::RunMessageLoop(); |
141 | 143 |
142 EXPECT_EQ(gdata::GDATA_PARSE_ERROR, result); | 144 EXPECT_EQ(gdata::GDATA_PARSE_ERROR, result); |
143 EXPECT_FALSE(result_data); | 145 EXPECT_FALSE(result_data); |
144 } | 146 } |
OLD | NEW |