| 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 "chrome/browser/google_apis/base_operations.h" | 5 #include "chrome/browser/google_apis/base_operations.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 const char kTestAuthToken[] = "testtoken"; | 28 const char kTestAuthToken[] = "testtoken"; |
| 29 const char kTestUserAgent[] = "test-user-agent"; | 29 const char kTestUserAgent[] = "test-user-agent"; |
| 30 | 30 |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 class BaseOperationsServerTest : public testing::Test { | 33 class BaseOperationsServerTest : public testing::Test { |
| 34 protected: | 34 protected: |
| 35 BaseOperationsServerTest() | 35 BaseOperationsServerTest() |
| 36 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 36 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
| 37 file_thread_(content::BrowserThread::FILE), | 37 file_thread_(content::BrowserThread::FILE), |
| 38 io_thread_(content::BrowserThread::IO) { | 38 io_thread_(content::BrowserThread::IO), |
| 39 test_server_(content::BrowserThread::GetMessageLoopProxyForThread( |
| 40 content::BrowserThread::IO)) { |
| 39 } | 41 } |
| 40 | 42 |
| 41 virtual void SetUp() OVERRIDE { | 43 virtual void SetUp() OVERRIDE { |
| 42 file_thread_.Start(); | 44 file_thread_.Start(); |
| 43 io_thread_.StartIOThread(); | 45 io_thread_.StartIOThread(); |
| 44 profile_.reset(new TestingProfile); | 46 profile_.reset(new TestingProfile); |
| 45 | 47 |
| 46 request_context_getter_ = new net::TestURLRequestContextGetter( | 48 request_context_getter_ = new net::TestURLRequestContextGetter( |
| 47 content::BrowserThread::GetMessageLoopProxyForThread( | 49 content::BrowserThread::GetMessageLoopProxyForThread( |
| 48 content::BrowserThread::IO)); | 50 content::BrowserThread::IO)); |
| 49 | 51 |
| 50 ASSERT_TRUE(test_server_.InitializeAndWaitUntilReady()); | 52 ASSERT_TRUE(test_server_.InitializeAndWaitUntilReady()); |
| 51 test_server_.RegisterRequestHandler( | 53 test_server_.RegisterRequestHandler( |
| 52 base::Bind(&test_util::HandleDownloadRequest, | 54 base::Bind(&test_util::HandleDownloadRequest, |
| 53 test_server_.base_url(), | 55 test_server_.base_url(), |
| 54 base::Unretained(&http_request_))); | 56 base::Unretained(&http_request_))); |
| 55 } | 57 } |
| 56 | 58 |
| 57 virtual void TearDown() OVERRIDE { | 59 virtual void TearDown() OVERRIDE { |
| 58 test_server_.ShutdownAndWaitUntilComplete(); | 60 EXPECT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); |
| 59 request_context_getter_ = NULL; | 61 request_context_getter_ = NULL; |
| 60 } | 62 } |
| 61 | 63 |
| 62 // Returns a temporary file path suitable for storing the cache file. | 64 // Returns a temporary file path suitable for storing the cache file. |
| 63 base::FilePath GetTestCachedFilePath(const base::FilePath& file_name) { | 65 base::FilePath GetTestCachedFilePath(const base::FilePath& file_name) { |
| 64 return profile_->GetPath().Append(file_name); | 66 return profile_->GetPath().Append(file_name); |
| 65 } | 67 } |
| 66 | 68 |
| 67 MessageLoopForUI message_loop_; | 69 MessageLoopForUI message_loop_; |
| 68 content::TestBrowserThread ui_thread_; | 70 content::TestBrowserThread ui_thread_; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 file_util::Delete(temp_file, false); | 141 file_util::Delete(temp_file, false); |
| 140 | 142 |
| 141 EXPECT_EQ(HTTP_NOT_FOUND, result_code); | 143 EXPECT_EQ(HTTP_NOT_FOUND, result_code); |
| 142 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 144 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 143 EXPECT_EQ("/files/chromeos/gdata/no-such-file.txt", | 145 EXPECT_EQ("/files/chromeos/gdata/no-such-file.txt", |
| 144 http_request_.relative_url); | 146 http_request_.relative_url); |
| 145 // Do not verify the not found message. | 147 // Do not verify the not found message. |
| 146 } | 148 } |
| 147 | 149 |
| 148 } // namespace google_apis | 150 } // namespace google_apis |
| OLD | NEW |