Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_wapi_service_browsertest.cc

Issue 10829375: Cleanup: separate WAPI and Drive API code in gdata_documents_service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for comments Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/gdata/gdata_documents_service.h" 10 #include "chrome/browser/chromeos/gdata/gdata_wapi_service.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "net/test/test_server.h" 15 #include "net/test/test_server.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace gdata { 18 namespace gdata {
19 19
20 namespace { 20 namespace {
21 21
22 class GDataTest : public InProcessBrowserTest { 22 class GDataTest : public InProcessBrowserTest {
23 public: 23 public:
24 GDataTest() 24 GDataTest()
25 : InProcessBrowserTest(), 25 : InProcessBrowserTest(),
26 gdata_test_server_(net::TestServer::TYPE_GDATA, 26 gdata_test_server_(net::TestServer::TYPE_GDATA,
27 net::TestServer::kLocalhost, 27 net::TestServer::kLocalhost,
28 FilePath(FILE_PATH_LITERAL("chrome/test/data"))) { 28 FilePath(FILE_PATH_LITERAL("chrome/test/data"))) {
29 } 29 }
30 30
31 virtual void SetUpOnMainThread() OVERRIDE { 31 virtual void SetUpOnMainThread() OVERRIDE {
32 ASSERT_TRUE(gdata_test_server_.Start()); 32 ASSERT_TRUE(gdata_test_server_.Start());
33 service_.reset(new gdata::DocumentsService); 33 service_.reset(new gdata::GDataWapiService);
34 service_->Initialize(browser()->profile()); 34 service_->Initialize(browser()->profile());
35 service_->auth_service_for_testing()->set_access_token_for_testing( 35 service_->auth_service_for_testing()->set_access_token_for_testing(
36 net::TestServer::kGDataAuthToken); 36 net::TestServer::kGDataAuthToken);
37 } 37 }
38 38
39 virtual void CleanUpOnMainThread() { 39 virtual void CleanUpOnMainThread() {
40 service_.reset(); 40 service_.reset();
41 } 41 }
42 42
43 protected: 43 protected:
44 FilePath GetTestCachedFilePath(const FilePath& file_name) { 44 FilePath GetTestCachedFilePath(const FilePath& file_name) {
45 return browser()->profile()->GetPath().Append(file_name); 45 return browser()->profile()->GetPath().Append(file_name);
46 } 46 }
47 47
48 net::TestServer gdata_test_server_; 48 net::TestServer gdata_test_server_;
49 scoped_ptr<gdata::DocumentsService> service_; 49 scoped_ptr<gdata::GDataWapiService> service_;
50 }; 50 };
51 51
52 // The test callback for DocumentsService::DownloadFile(). 52 // The test callback for GDataWapiService::DownloadFile().
53 void TestDownloadCallback(gdata::GDataErrorCode* result, 53 void TestDownloadCallback(gdata::GDataErrorCode* result,
54 std::string* contents, 54 std::string* contents,
55 gdata::GDataErrorCode error, 55 gdata::GDataErrorCode error,
56 const GURL& content_url, 56 const GURL& content_url,
57 const FilePath& temp_file) { 57 const FilePath& temp_file) {
58 *result = error; 58 *result = error;
59 file_util::ReadFileToString(temp_file, contents); 59 file_util::ReadFileToString(temp_file, contents);
60 file_util::Delete(temp_file, false); 60 file_util::Delete(temp_file, false);
61 MessageLoop::current()->Quit(); 61 MessageLoop::current()->Quit();
62 } 62 }
63 63
64 // The test callback for DocumentsService::GetDocuments(). 64 // The test callback for GDataWapiService::GetDocuments().
65 void TestGetDocumentsCallback(gdata::GDataErrorCode* result_code, 65 void TestGetDocumentsCallback(gdata::GDataErrorCode* result_code,
66 base::Value** result_data, 66 base::Value** result_data,
67 gdata::GDataErrorCode error, 67 gdata::GDataErrorCode error,
68 scoped_ptr<base::Value> feed_data) { 68 scoped_ptr<base::Value> feed_data) {
69 *result_code = error; 69 *result_code = error;
70 *result_data = feed_data.release(); 70 *result_data = feed_data.release();
71 MessageLoop::current()->Quit(); 71 MessageLoop::current()->Quit();
72 } 72 }
73 73
74 } // namespace 74 } // namespace
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 std::string(), // search string 141 std::string(), // search string
142 std::string(), // directory resource ID 142 std::string(), // directory resource ID
143 base::Bind(&TestGetDocumentsCallback, &result, &result_data)); 143 base::Bind(&TestGetDocumentsCallback, &result, &result_data));
144 content::RunMessageLoop(); 144 content::RunMessageLoop();
145 145
146 EXPECT_EQ(gdata::GDATA_PARSE_ERROR, result); 146 EXPECT_EQ(gdata::GDATA_PARSE_ERROR, result);
147 EXPECT_FALSE(result_data); 147 EXPECT_FALSE(result_data);
148 } 148 }
149 149
150 } // namespace gdata 150 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_wapi_service.cc ('k') | chrome/browser/chromeos/gdata/mock_documents_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698