| Index: chrome/browser/chromeos/gdata/gdata_wapi_service_browsertest.cc
|
| diff --git a/chrome/browser/chromeos/gdata/gdata_wapi_service_browsertest.cc b/chrome/browser/chromeos/gdata/gdata_wapi_service_browsertest.cc
|
| index 5aac75c31af6e42d066bae325944e387afa8dbcc..386fd2b9c6b5587b70cfb15b92ef37293782909f 100644
|
| --- a/chrome/browser/chromeos/gdata/gdata_wapi_service_browsertest.cc
|
| +++ b/chrome/browser/chromeos/gdata/gdata_wapi_service_browsertest.cc
|
| @@ -8,11 +8,11 @@
|
| #include "base/file_util.h"
|
| #include "base/json/json_reader.h"
|
| #include "chrome/browser/chromeos/gdata/gdata_wapi_service.h"
|
| +#include "chrome/browser/chromeos/gdata/test_servers/http_test_server.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/test/base/in_process_browser_test.h"
|
| #include "chrome/test/base/ui_test_utils.h"
|
| -#include "net/test/test_server.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace gdata {
|
| @@ -22,22 +22,35 @@ namespace {
|
| class GDataTest : public InProcessBrowserTest {
|
| public:
|
| GDataTest()
|
| - : InProcessBrowserTest(),
|
| - gdata_test_server_(net::TestServer::TYPE_GDATA,
|
| - net::TestServer::kLocalhost,
|
| - FilePath(FILE_PATH_LITERAL("chrome/test/data"))) {
|
| + : InProcessBrowserTest() {
|
| }
|
|
|
| virtual void SetUpOnMainThread() OVERRIDE {
|
| - ASSERT_TRUE(gdata_test_server_.Start());
|
| service_.reset(new gdata::GDataWapiService);
|
| service_->Initialize(browser()->profile());
|
| service_->auth_service_for_testing()->set_access_token_for_testing(
|
| net::TestServer::kGDataAuthToken);
|
| + gdata_test_server_.reset(new gdata::test_servers::HttpTestServer(true));
|
| + SetUpTestServer();
|
| + }
|
| +
|
| + virtual void SetUpTestServer() {
|
| + test_server_file_url_ = gdata_test_server_->RegisterFileResponse(
|
| + "some/path/testfile.txt",
|
| + FilePath(FILE_PATH_LITERAL(
|
| + "chrome/test/data/chromeos/gdata/testfile.txt")),
|
| + "text/plain",
|
| + gdata::test_servers::SUCCESS);
|
| +
|
| + test_server_root_feed_url_ = gdata_test_server_->RegisterFileResponse(
|
| + FilePath(FILE_PATH_LITERAL(
|
| + "chrome/test/data/chromeos/gdata/root_feed.json")),
|
| + "text/json");
|
| }
|
|
|
| virtual void CleanUpOnMainThread() {
|
| service_.reset();
|
| + gdata_test_server_.reset();
|
| }
|
|
|
| protected:
|
| @@ -45,8 +58,10 @@ class GDataTest : public InProcessBrowserTest {
|
| return browser()->profile()->GetPath().Append(file_name);
|
| }
|
|
|
| - net::TestServer gdata_test_server_;
|
| + scoped_ptr<gdata::test_servers::HttpTestServer> gdata_test_server_;
|
| scoped_ptr<gdata::GDataWapiService> service_;
|
| + GURL test_server_file_url_;
|
| + GURL test_server_root_feed_url_;
|
| };
|
|
|
| // The test callback for GDataWapiService::DownloadFile().
|
| @@ -79,14 +94,14 @@ IN_PROC_BROWSER_TEST_F(GDataTest, Download) {
|
| service_->DownloadFile(
|
| FilePath("/dummy/gdata/testfile.txt"),
|
| GetTestCachedFilePath(FilePath("cached_testfile.txt")),
|
| - gdata_test_server_.GetURL("files/chromeos/gdata/testfile.txt"),
|
| + test_server_file_url_,
|
| base::Bind(&TestDownloadCallback, &result, &contents),
|
| gdata::GetContentCallback());
|
| content::RunMessageLoop();
|
|
|
| EXPECT_EQ(gdata::HTTP_SUCCESS, result);
|
| - FilePath expected_filepath = gdata_test_server_.document_root().Append(
|
| - FilePath(FILE_PATH_LITERAL("chromeos/gdata/testfile.txt")));
|
| + FilePath expected_filepath = FilePath(
|
| + FILE_PATH_LITERAL("chrome/test/data/chromeos/gdata/testfile.txt"));
|
| std::string expected_contents;
|
| file_util::ReadFileToString(expected_filepath, &expected_contents);
|
| EXPECT_EQ(expected_contents, contents);
|
| @@ -98,7 +113,7 @@ IN_PROC_BROWSER_TEST_F(GDataTest, NonExistingDownload) {
|
| service_->DownloadFile(
|
| FilePath("/dummy/gdata/no-such-file.txt"),
|
| GetTestCachedFilePath(FilePath("cache_no-such-file.txt")),
|
| - gdata_test_server_.GetURL("files/chromeos/gdata/no-such-file.txt"),
|
| + gdata_test_server_->GetErrorURL(gdata::test_servers::NOT_FOUND),
|
| base::Bind(&TestDownloadCallback, &result, &dummy_contents),
|
| gdata::GetContentCallback());
|
| content::RunMessageLoop();
|
| @@ -111,7 +126,7 @@ IN_PROC_BROWSER_TEST_F(GDataTest, GetDocuments) {
|
| gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR;
|
| base::Value* result_data = NULL;
|
| service_->GetDocuments(
|
| - gdata_test_server_.GetURL("files/chromeos/gdata/root_feed.json"),
|
| + test_server_root_feed_url_,
|
| 0, // start_changestamp
|
| std::string(), // search string
|
| std::string(), // directory resource ID
|
| @@ -120,8 +135,8 @@ IN_PROC_BROWSER_TEST_F(GDataTest, GetDocuments) {
|
|
|
| EXPECT_EQ(gdata::HTTP_SUCCESS, result);
|
| ASSERT_TRUE(result_data);
|
| - FilePath expected_filepath = gdata_test_server_.document_root().Append(
|
| - FilePath(FILE_PATH_LITERAL("chromeos/gdata/root_feed.json")));
|
| + FilePath expected_filepath = FilePath(
|
| + FILE_PATH_LITERAL("chrome/test/data/chromeos/gdata/root_feed.json"));
|
| std::string expected_contents;
|
| file_util::ReadFileToString(expected_filepath, &expected_contents);
|
| scoped_ptr<base::Value> expected_data(
|
| @@ -136,7 +151,7 @@ IN_PROC_BROWSER_TEST_F(GDataTest, GetDocumentsFailure) {
|
| gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR;
|
| base::Value* result_data = NULL;
|
| service_->GetDocuments(
|
| - gdata_test_server_.GetURL("files/chromeos/gdata/testfile.txt"),
|
| + test_server_file_url_,
|
| 0, // start_changestamp
|
| std::string(), // search string
|
| std::string(), // directory resource ID
|
|
|