| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 request_context_getter_ = new net::TestURLRequestContextGetter( | 122 request_context_getter_ = new net::TestURLRequestContextGetter( |
| 123 message_loop_.task_runner()); | 123 message_loop_.task_runner()); |
| 124 | 124 |
| 125 request_sender_.reset(new RequestSender(new DummyAuthService, | 125 request_sender_.reset(new RequestSender(new DummyAuthService, |
| 126 request_context_getter_.get(), | 126 request_context_getter_.get(), |
| 127 message_loop_.task_runner(), | 127 message_loop_.task_runner(), |
| 128 kTestUserAgent)); | 128 kTestUserAgent)); |
| 129 | 129 |
| 130 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 130 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 131 | 131 |
| 132 ASSERT_TRUE(test_server_.InitializeAndWaitUntilReady()); | 132 ASSERT_TRUE(test_server_.Start()); |
| 133 test_server_.RegisterRequestHandler( | 133 test_server_.RegisterRequestHandler( |
| 134 base::Bind(&DriveApiRequestsTest::HandleChildrenDeleteRequest, | 134 base::Bind(&DriveApiRequestsTest::HandleChildrenDeleteRequest, |
| 135 base::Unretained(this))); | 135 base::Unretained(this))); |
| 136 test_server_.RegisterRequestHandler( | 136 test_server_.RegisterRequestHandler( |
| 137 base::Bind(&DriveApiRequestsTest::HandleDataFileRequest, | 137 base::Bind(&DriveApiRequestsTest::HandleDataFileRequest, |
| 138 base::Unretained(this))); | 138 base::Unretained(this))); |
| 139 test_server_.RegisterRequestHandler( | 139 test_server_.RegisterRequestHandler( |
| 140 base::Bind(&DriveApiRequestsTest::HandleDeleteRequest, | 140 base::Bind(&DriveApiRequestsTest::HandleDeleteRequest, |
| 141 base::Unretained(this))); | 141 base::Unretained(this))); |
| 142 test_server_.RegisterRequestHandler( | 142 test_server_.RegisterRequestHandler( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 public_property.set_visibility(drive::Property::VISIBILITY_PUBLIC); | 176 public_property.set_visibility(drive::Property::VISIBILITY_PUBLIC); |
| 177 public_property.set_key("key2"); | 177 public_property.set_key("key2"); |
| 178 public_property.set_value("value2"); | 178 public_property.set_value("value2"); |
| 179 | 179 |
| 180 testing_properties_.clear(); | 180 testing_properties_.clear(); |
| 181 testing_properties_.push_back(private_property); | 181 testing_properties_.push_back(private_property); |
| 182 testing_properties_.push_back(public_property); | 182 testing_properties_.push_back(public_property); |
| 183 } | 183 } |
| 184 | 184 |
| 185 base::MessageLoopForIO message_loop_; // Test server needs IO thread. | 185 base::MessageLoopForIO message_loop_; // Test server needs IO thread. |
| 186 net::test_server::EmbeddedTestServer test_server_; | 186 net::EmbeddedTestServer test_server_; |
| 187 scoped_ptr<RequestSender> request_sender_; | 187 scoped_ptr<RequestSender> request_sender_; |
| 188 scoped_ptr<DriveApiUrlGenerator> url_generator_; | 188 scoped_ptr<DriveApiUrlGenerator> url_generator_; |
| 189 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; | 189 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; |
| 190 base::ScopedTempDir temp_dir_; | 190 base::ScopedTempDir temp_dir_; |
| 191 | 191 |
| 192 // This is a path to the file which contains expected response from | 192 // This is a path to the file which contains expected response from |
| 193 // the server. See also HandleDataFileRequest below. | 193 // the server. See also HandleDataFileRequest below. |
| 194 base::FilePath expected_data_file_path_; | 194 base::FilePath expected_data_file_path_; |
| 195 | 195 |
| 196 // This is a path string in the expected response header from the server | 196 // This is a path string in the expected response header from the server |
| (...skipping 2087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2284 "Header: value\r\n" | 2284 "Header: value\r\n" |
| 2285 "\r\n" | 2285 "\r\n" |
| 2286 "BODY\r\n" | 2286 "BODY\r\n" |
| 2287 "--BOUNDARY-- \t", | 2287 "--BOUNDARY-- \t", |
| 2288 &parts)); | 2288 &parts)); |
| 2289 ASSERT_EQ(1u, parts.size()); | 2289 ASSERT_EQ(1u, parts.size()); |
| 2290 EXPECT_EQ(HTTP_SUCCESS, parts[0].code); | 2290 EXPECT_EQ(HTTP_SUCCESS, parts[0].code); |
| 2291 EXPECT_EQ("BODY", parts[0].body); | 2291 EXPECT_EQ("BODY", parts[0].body); |
| 2292 } | 2292 } |
| 2293 } // namespace google_apis | 2293 } // namespace google_apis |
| OLD | NEW |