| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/json/json_writer.h" | 5 #include "base/json/json_writer.h" |
| 6 #include "base/values.h" | 6 #include "base/values.h" |
| 7 #include "chrome/browser/extensions/api/copresence/copresence_api.h" | 7 #include "chrome/browser/extensions/api/copresence/copresence_api.h" |
| 8 #include "chrome/browser/extensions/extension_api_unittest.h" | 8 #include "chrome/browser/extensions/extension_api_unittest.h" |
| 9 #include "chrome/browser/extensions/extension_function_test_utils.h" | 9 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 10 #include "components/copresence/proto/data.pb.h" | 10 #include "components/copresence/proto/data.pb.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 class MockCopresenceManager : public CopresenceManager { | 70 class MockCopresenceManager : public CopresenceManager { |
| 71 public: | 71 public: |
| 72 explicit MockCopresenceManager(CopresenceDelegate* delegate) | 72 explicit MockCopresenceManager(CopresenceDelegate* delegate) |
| 73 : delegate_(delegate) {} | 73 : delegate_(delegate) {} |
| 74 virtual ~MockCopresenceManager() {} | 74 virtual ~MockCopresenceManager() {} |
| 75 | 75 |
| 76 virtual void ExecuteReportRequest( | 76 virtual void ExecuteReportRequest( |
| 77 ReportRequest request, | 77 ReportRequest request, |
| 78 const std::string& app_id, | 78 const std::string& app_id, |
| 79 const copresence::StatusCallback& status_callback) OVERRIDE { | 79 const copresence::StatusCallback& status_callback) override { |
| 80 request_ = request; | 80 request_ = request; |
| 81 app_id_ = app_id; | 81 app_id_ = app_id; |
| 82 status_callback.Run(copresence::SUCCESS); | 82 status_callback.Run(copresence::SUCCESS); |
| 83 } | 83 } |
| 84 | 84 |
| 85 CopresenceDelegate* delegate_; | 85 CopresenceDelegate* delegate_; |
| 86 | 86 |
| 87 ReportRequest request_; | 87 ReportRequest request_; |
| 88 std::string app_id_; | 88 std::string app_id_; |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 class CopresenceApiUnittest : public ExtensionApiUnittest { | 91 class CopresenceApiUnittest : public ExtensionApiUnittest { |
| 92 public: | 92 public: |
| 93 CopresenceApiUnittest() {} | 93 CopresenceApiUnittest() {} |
| 94 virtual ~CopresenceApiUnittest() {} | 94 virtual ~CopresenceApiUnittest() {} |
| 95 | 95 |
| 96 virtual void SetUp() OVERRIDE { | 96 virtual void SetUp() override { |
| 97 ExtensionApiUnittest::SetUp(); | 97 ExtensionApiUnittest::SetUp(); |
| 98 | 98 |
| 99 CopresenceService* service = | 99 CopresenceService* service = |
| 100 CopresenceService::GetFactoryInstance()->Get(profile()); | 100 CopresenceService::GetFactoryInstance()->Get(profile()); |
| 101 copresence_manager_ = new MockCopresenceManager(service); | 101 copresence_manager_ = new MockCopresenceManager(service); |
| 102 service->set_manager_for_testing( | 102 service->set_manager_for_testing( |
| 103 make_scoped_ptr<CopresenceManager>(copresence_manager_)); | 103 make_scoped_ptr<CopresenceManager>(copresence_manager_)); |
| 104 } | 104 } |
| 105 | 105 |
| 106 // Takes ownership of the operation_list. | 106 // Takes ownership of the operation_list. |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 264 |
| 265 TEST_F(CopresenceApiUnittest, MultipleOperations) { | 265 TEST_F(CopresenceApiUnittest, MultipleOperations) { |
| 266 scoped_ptr<Operation> multi_operation(new Operation); | 266 scoped_ptr<Operation> multi_operation(new Operation); |
| 267 multi_operation->publish.reset(CreatePublish("pub")); | 267 multi_operation->publish.reset(CreatePublish("pub")); |
| 268 multi_operation->subscribe.reset(CreateSubscribe("sub")); | 268 multi_operation->subscribe.reset(CreateSubscribe("sub")); |
| 269 | 269 |
| 270 EXPECT_FALSE(ExecuteOperation(multi_operation.Pass())); | 270 EXPECT_FALSE(ExecuteOperation(multi_operation.Pass())); |
| 271 } | 271 } |
| 272 | 272 |
| 273 } // namespace extensions | 273 } // namespace extensions |
| OLD | NEW |