| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <map> | 6 #include <map> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 const char kTestGDataAuthToken[] = "testtoken"; | 37 const char kTestGDataAuthToken[] = "testtoken"; |
| 38 const char kTestUserAgent[] = "test-user-agent"; | 38 const char kTestUserAgent[] = "test-user-agent"; |
| 39 const char kTestETag[] = "test_etag"; | 39 const char kTestETag[] = "test_etag"; |
| 40 | 40 |
| 41 class GDataWapiOperationsTest : public testing::Test { | 41 class GDataWapiOperationsTest : public testing::Test { |
| 42 public: | 42 public: |
| 43 GDataWapiOperationsTest() | 43 GDataWapiOperationsTest() |
| 44 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 44 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
| 45 file_thread_(content::BrowserThread::FILE), | 45 file_thread_(content::BrowserThread::FILE), |
| 46 io_thread_(content::BrowserThread::IO) { | 46 io_thread_(content::BrowserThread::IO), |
| 47 test_server_(content::BrowserThread::GetMessageLoopProxyForThread( |
| 48 content::BrowserThread::IO)) { |
| 47 } | 49 } |
| 48 | 50 |
| 49 virtual void SetUp() OVERRIDE { | 51 virtual void SetUp() OVERRIDE { |
| 50 file_thread_.Start(); | 52 file_thread_.Start(); |
| 51 io_thread_.StartIOThread(); | 53 io_thread_.StartIOThread(); |
| 52 profile_.reset(new TestingProfile); | 54 profile_.reset(new TestingProfile); |
| 53 | 55 |
| 54 request_context_getter_ = new net::TestURLRequestContextGetter( | 56 request_context_getter_ = new net::TestURLRequestContextGetter( |
| 55 content::BrowserThread::GetMessageLoopProxyForThread( | 57 content::BrowserThread::GetMessageLoopProxyForThread( |
| 56 content::BrowserThread::IO)); | 58 content::BrowserThread::IO)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 74 base::Unretained(this))); | 76 base::Unretained(this))); |
| 75 | 77 |
| 76 url_generator_.reset(new GDataWapiUrlGenerator( | 78 url_generator_.reset(new GDataWapiUrlGenerator( |
| 77 test_util::GetBaseUrlForTesting(test_server_.port()))); | 79 test_util::GetBaseUrlForTesting(test_server_.port()))); |
| 78 | 80 |
| 79 received_bytes_ = 0; | 81 received_bytes_ = 0; |
| 80 content_length_ = 0; | 82 content_length_ = 0; |
| 81 } | 83 } |
| 82 | 84 |
| 83 virtual void TearDown() OVERRIDE { | 85 virtual void TearDown() OVERRIDE { |
| 84 test_server_.ShutdownAndWaitUntilComplete(); | 86 EXPECT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); |
| 85 request_context_getter_ = NULL; | 87 request_context_getter_ = NULL; |
| 86 } | 88 } |
| 87 | 89 |
| 88 protected: | 90 protected: |
| 89 // Handles a request for fetching a resource feed. | 91 // Handles a request for fetching a resource feed. |
| 90 scoped_ptr<test_server::HttpResponse> HandleResourceFeedRequest( | 92 scoped_ptr<test_server::HttpResponse> HandleResourceFeedRequest( |
| 91 const test_server::HttpRequest& request) { | 93 const test_server::HttpRequest& request) { |
| 92 http_request_ = request; | 94 http_request_ = request; |
| 93 | 95 |
| 94 const GURL absolute_url = test_server_.GetURL(request.relative_url); | 96 const GURL absolute_url = test_server_.GetURL(request.relative_url); |
| (...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), | 1457 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), |
| 1456 http_request_.headers["X-Upload-Content-Length"]); | 1458 http_request_.headers["X-Upload-Content-Length"]); |
| 1457 // For updating an existing file, an empty body should be attached (PUT | 1459 // For updating an existing file, an empty body should be attached (PUT |
| 1458 // requires a body) | 1460 // requires a body) |
| 1459 EXPECT_TRUE(http_request_.has_content); | 1461 EXPECT_TRUE(http_request_.has_content); |
| 1460 EXPECT_EQ("", http_request_.content); | 1462 EXPECT_EQ("", http_request_.content); |
| 1461 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); | 1463 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); |
| 1462 } | 1464 } |
| 1463 | 1465 |
| 1464 } // namespace google_apis | 1466 } // namespace google_apis |
| OLD | NEW |