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/drive/gdata_wapi_service.h" | 10 #include "chrome/browser/chromeos/drive/gdata_wapi_service.h" |
11 #include "chrome/browser/google_apis/auth_service.h" | 11 #include "chrome/browser/google_apis/auth_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
16 #include "net/test/test_server.h" | 16 #include "net/test/test_server.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 namespace gdata { | 19 namespace drive { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 class GDataTest : public InProcessBrowserTest { | 23 class GDataTest : public InProcessBrowserTest { |
24 public: | 24 public: |
25 GDataTest() | 25 GDataTest() |
26 : InProcessBrowserTest(), | 26 : InProcessBrowserTest(), |
27 gdata_test_server_(net::TestServer::TYPE_GDATA, | 27 gdata_test_server_(net::TestServer::TYPE_GDATA, |
28 net::TestServer::kLocalhost, | 28 net::TestServer::kLocalhost, |
29 FilePath(FILE_PATH_LITERAL("chrome/test/data"))) { | 29 FilePath(FILE_PATH_LITERAL("chrome/test/data"))) { |
30 } | 30 } |
31 | 31 |
32 virtual void SetUpOnMainThread() OVERRIDE { | 32 virtual void SetUpOnMainThread() OVERRIDE { |
33 ASSERT_TRUE(gdata_test_server_.Start()); | 33 ASSERT_TRUE(gdata_test_server_.Start()); |
34 service_.reset(new gdata::GDataWapiService); | 34 service_.reset(new GDataWapiService); |
35 service_->Initialize(browser()->profile()); | 35 service_->Initialize(browser()->profile()); |
36 service_->auth_service_for_testing()->set_access_token_for_testing( | 36 service_->auth_service_for_testing()->set_access_token_for_testing( |
37 net::TestServer::kGDataAuthToken); | 37 net::TestServer::kGDataAuthToken); |
38 } | 38 } |
39 | 39 |
40 virtual void CleanUpOnMainThread() { | 40 virtual void CleanUpOnMainThread() { |
41 service_.reset(); | 41 service_.reset(); |
42 } | 42 } |
43 | 43 |
44 protected: | 44 protected: |
45 FilePath GetTestCachedFilePath(const FilePath& file_name) { | 45 FilePath GetTestCachedFilePath(const FilePath& file_name) { |
46 return browser()->profile()->GetPath().Append(file_name); | 46 return browser()->profile()->GetPath().Append(file_name); |
47 } | 47 } |
48 | 48 |
49 net::TestServer gdata_test_server_; | 49 net::TestServer gdata_test_server_; |
50 scoped_ptr<gdata::GDataWapiService> service_; | 50 scoped_ptr<GDataWapiService> service_; |
51 }; | 51 }; |
52 | 52 |
53 // The test callback for GDataWapiService::DownloadFile(). | 53 // The test callback for GDataWapiService::DownloadFile(). |
54 void TestDownloadCallback(gdata::GDataErrorCode* result, | 54 void TestDownloadCallback(gdata::GDataErrorCode* result, |
55 std::string* contents, | 55 std::string* contents, |
56 gdata::GDataErrorCode error, | 56 gdata::GDataErrorCode error, |
57 const GURL& content_url, | 57 const GURL& content_url, |
58 const FilePath& temp_file) { | 58 const FilePath& temp_file) { |
59 *result = error; | 59 *result = error; |
60 file_util::ReadFileToString(temp_file, contents); | 60 file_util::ReadFileToString(temp_file, contents); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 0, // start_changestamp | 141 0, // start_changestamp |
142 std::string(), // search string | 142 std::string(), // search string |
143 std::string(), // directory resource ID | 143 std::string(), // directory resource ID |
144 base::Bind(&TestGetDocumentsCallback, &result, &result_data)); | 144 base::Bind(&TestGetDocumentsCallback, &result, &result_data)); |
145 content::RunMessageLoop(); | 145 content::RunMessageLoop(); |
146 | 146 |
147 EXPECT_EQ(gdata::GDATA_PARSE_ERROR, result); | 147 EXPECT_EQ(gdata::GDATA_PARSE_ERROR, result); |
148 EXPECT_FALSE(result_data); | 148 EXPECT_FALSE(result_data); |
149 } | 149 } |
150 | 150 |
151 } // namespace gdata | 151 } // namespace drive |
OLD | NEW |