| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "remoting/host/setup/me2me_native_messaging_host.h" | 5 #include "remoting/host/setup/me2me_native_messaging_host.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 namespace remoting { | 133 namespace remoting { |
| 134 | 134 |
| 135 class MockDaemonControllerDelegate : public DaemonController::Delegate { | 135 class MockDaemonControllerDelegate : public DaemonController::Delegate { |
| 136 public: | 136 public: |
| 137 MockDaemonControllerDelegate(); | 137 MockDaemonControllerDelegate(); |
| 138 virtual ~MockDaemonControllerDelegate(); | 138 virtual ~MockDaemonControllerDelegate(); |
| 139 | 139 |
| 140 // DaemonController::Delegate interface. | 140 // DaemonController::Delegate interface. |
| 141 virtual DaemonController::State GetState() OVERRIDE; | 141 virtual DaemonController::State GetState() OVERRIDE; |
| 142 virtual scoped_ptr<base::DictionaryValue> GetConfig() OVERRIDE; | 142 virtual scoped_ptr<base::DictionaryValue> GetConfig() OVERRIDE; |
| 143 virtual void InstallHost( |
| 144 const DaemonController::CompletionCallback& done) OVERRIDE; |
| 143 virtual void SetConfigAndStart( | 145 virtual void SetConfigAndStart( |
| 144 scoped_ptr<base::DictionaryValue> config, | 146 scoped_ptr<base::DictionaryValue> config, |
| 145 bool consent, | 147 bool consent, |
| 146 const DaemonController::CompletionCallback& done) OVERRIDE; | 148 const DaemonController::CompletionCallback& done) OVERRIDE; |
| 147 virtual void UpdateConfig( | 149 virtual void UpdateConfig( |
| 148 scoped_ptr<base::DictionaryValue> config, | 150 scoped_ptr<base::DictionaryValue> config, |
| 149 const DaemonController::CompletionCallback& done) OVERRIDE; | 151 const DaemonController::CompletionCallback& done) OVERRIDE; |
| 150 virtual void Stop(const DaemonController::CompletionCallback& done) OVERRIDE; | 152 virtual void Stop(const DaemonController::CompletionCallback& done) OVERRIDE; |
| 151 virtual void SetWindow(void* window_handle) OVERRIDE; | 153 virtual void SetWindow(void* window_handle) OVERRIDE; |
| 152 virtual std::string GetVersion() OVERRIDE; | 154 virtual std::string GetVersion() OVERRIDE; |
| 153 virtual DaemonController::UsageStatsConsent GetUsageStatsConsent() OVERRIDE; | 155 virtual DaemonController::UsageStatsConsent GetUsageStatsConsent() OVERRIDE; |
| 154 | 156 |
| 155 private: | 157 private: |
| 156 DISALLOW_COPY_AND_ASSIGN(MockDaemonControllerDelegate); | 158 DISALLOW_COPY_AND_ASSIGN(MockDaemonControllerDelegate); |
| 157 }; | 159 }; |
| 158 | 160 |
| 159 MockDaemonControllerDelegate::MockDaemonControllerDelegate() {} | 161 MockDaemonControllerDelegate::MockDaemonControllerDelegate() {} |
| 160 | 162 |
| 161 MockDaemonControllerDelegate::~MockDaemonControllerDelegate() {} | 163 MockDaemonControllerDelegate::~MockDaemonControllerDelegate() {} |
| 162 | 164 |
| 163 DaemonController::State MockDaemonControllerDelegate::GetState() { | 165 DaemonController::State MockDaemonControllerDelegate::GetState() { |
| 164 return DaemonController::STATE_STARTED; | 166 return DaemonController::STATE_STARTED; |
| 165 } | 167 } |
| 166 | 168 |
| 167 scoped_ptr<base::DictionaryValue> MockDaemonControllerDelegate::GetConfig() { | 169 scoped_ptr<base::DictionaryValue> MockDaemonControllerDelegate::GetConfig() { |
| 168 return scoped_ptr<base::DictionaryValue>(new base::DictionaryValue()); | 170 return scoped_ptr<base::DictionaryValue>(new base::DictionaryValue()); |
| 169 } | 171 } |
| 170 | 172 |
| 173 void MockDaemonControllerDelegate::InstallHost( |
| 174 const DaemonController::CompletionCallback& done) { |
| 175 done.Run(DaemonController::RESULT_OK); |
| 176 } |
| 177 |
| 171 void MockDaemonControllerDelegate::SetConfigAndStart( | 178 void MockDaemonControllerDelegate::SetConfigAndStart( |
| 172 scoped_ptr<base::DictionaryValue> config, | 179 scoped_ptr<base::DictionaryValue> config, |
| 173 bool consent, | 180 bool consent, |
| 174 const DaemonController::CompletionCallback& done) { | 181 const DaemonController::CompletionCallback& done) { |
| 175 | 182 |
| 176 // Verify parameters passed in. | 183 // Verify parameters passed in. |
| 177 if (consent && config && config->HasKey("start")) { | 184 if (consent && config && config->HasKey("start")) { |
| 178 done.Run(DaemonController::RESULT_OK); | 185 done.Run(DaemonController::RESULT_OK); |
| 179 } else { | 186 } else { |
| 180 done.Run(DaemonController::RESULT_FAILED); | 187 done.Run(DaemonController::RESULT_FAILED); |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 | 601 |
| 595 // Verify rejection if startDaemon request has no "consent" parameter. | 602 // Verify rejection if startDaemon request has no "consent" parameter. |
| 596 TEST_F(Me2MeNativeMessagingHostTest, StartDaemonNoConsent) { | 603 TEST_F(Me2MeNativeMessagingHostTest, StartDaemonNoConsent) { |
| 597 base::DictionaryValue message; | 604 base::DictionaryValue message; |
| 598 message.SetString("type", "startDaemon"); | 605 message.SetString("type", "startDaemon"); |
| 599 message.Set("config", base::DictionaryValue().DeepCopy()); | 606 message.Set("config", base::DictionaryValue().DeepCopy()); |
| 600 TestBadRequest(message); | 607 TestBadRequest(message); |
| 601 } | 608 } |
| 602 | 609 |
| 603 } // namespace remoting | 610 } // namespace remoting |
| OLD | NEW |