| 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 "chrome/browser/google_apis/base_requests.h" | 5 #include "chrome/browser/google_apis/base_requests.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" |
| 9 #include "base/values.h" | 10 #include "base/values.h" |
| 10 #include "chrome/browser/google_apis/request_sender.h" | 11 #include "chrome/browser/google_apis/request_sender.h" |
| 11 #include "chrome/browser/google_apis/test_util.h" | 12 #include "chrome/browser/google_apis/test_util.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace google_apis { | 16 namespace google_apis { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 const char kValidJsonString[] = "{ \"test\": 123 }"; | 20 const char kValidJsonString[] = "{ \"test\": 123 }"; |
| 21 const char kInvalidJsonString[] = "$$$"; | 21 const char kInvalidJsonString[] = "$$$"; |
| 22 | 22 |
| 23 class FakeGetDataRequest : public GetDataRequest { | 23 class FakeGetDataRequest : public GetDataRequest { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 43 public: | 43 public: |
| 44 virtual void SetUp() OVERRIDE { | 44 virtual void SetUp() OVERRIDE { |
| 45 profile_.reset(new TestingProfile); | 45 profile_.reset(new TestingProfile); |
| 46 sender_.reset(new RequestSender(profile_.get(), | 46 sender_.reset(new RequestSender(profile_.get(), |
| 47 NULL /* url_request_context_getter */, | 47 NULL /* url_request_context_getter */, |
| 48 std::vector<std::string>() /* scopes */, | 48 std::vector<std::string>() /* scopes */, |
| 49 std::string() /* custom user agent */)); | 49 std::string() /* custom user agent */)); |
| 50 sender_->Initialize(); | 50 sender_->Initialize(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 content::TestBrowserThreadBundle thread_bundle_; | 53 base::MessageLoop message_loop_; |
| 54 scoped_ptr<TestingProfile> profile_; | 54 scoped_ptr<TestingProfile> profile_; |
| 55 scoped_ptr<RequestSender> sender_; | 55 scoped_ptr<RequestSender> sender_; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 TEST_F(BaseRequestsTest, ParseValidJson) { | 58 TEST_F(BaseRequestsTest, ParseValidJson) { |
| 59 scoped_ptr<base::Value> json; | 59 scoped_ptr<base::Value> json; |
| 60 ParseJson(kValidJsonString, | 60 ParseJson(kValidJsonString, |
| 61 base::Bind(test_util::CreateCopyResultCallback(&json))); | 61 base::Bind(test_util::CreateCopyResultCallback(&json))); |
| 62 // Should wait for a blocking pool task, as the JSON parsing is done in the | 62 // Should wait for a blocking pool task, as the JSON parsing is done in the |
| 63 // blocking pool. | 63 // blocking pool. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 get_data_request->ParseResponse(HTTP_SUCCESS, kInvalidJsonString); | 112 get_data_request->ParseResponse(HTTP_SUCCESS, kInvalidJsonString); |
| 113 // Should wait for a blocking pool task, as the JSON parsing is done in the | 113 // Should wait for a blocking pool task, as the JSON parsing is done in the |
| 114 // blocking pool. | 114 // blocking pool. |
| 115 test_util::RunBlockingPoolTask(); | 115 test_util::RunBlockingPoolTask(); |
| 116 | 116 |
| 117 EXPECT_EQ(GDATA_PARSE_ERROR, error); | 117 EXPECT_EQ(GDATA_PARSE_ERROR, error); |
| 118 EXPECT_FALSE(value); | 118 EXPECT_FALSE(value); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace google_apis | 121 } // namespace google_apis |
| OLD | NEW |