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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } // namespace | 131 } // namespace |
132 | 132 |
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( | 143 virtual void InstallHost( |
144 const DaemonController::CompletionCallback& done) OVERRIDE; | 144 const DaemonController::CompletionCallback& done) override; |
145 virtual void SetConfigAndStart( | 145 virtual void SetConfigAndStart( |
146 scoped_ptr<base::DictionaryValue> config, | 146 scoped_ptr<base::DictionaryValue> config, |
147 bool consent, | 147 bool consent, |
148 const DaemonController::CompletionCallback& done) OVERRIDE; | 148 const DaemonController::CompletionCallback& done) override; |
149 virtual void UpdateConfig( | 149 virtual void UpdateConfig( |
150 scoped_ptr<base::DictionaryValue> config, | 150 scoped_ptr<base::DictionaryValue> config, |
151 const DaemonController::CompletionCallback& done) OVERRIDE; | 151 const DaemonController::CompletionCallback& done) override; |
152 virtual void Stop(const DaemonController::CompletionCallback& done) OVERRIDE; | 152 virtual void Stop(const DaemonController::CompletionCallback& done) override; |
153 virtual void SetWindow(void* window_handle) OVERRIDE; | 153 virtual void SetWindow(void* window_handle) override; |
154 virtual std::string GetVersion() OVERRIDE; | 154 virtual std::string GetVersion() override; |
155 virtual DaemonController::UsageStatsConsent GetUsageStatsConsent() OVERRIDE; | 155 virtual DaemonController::UsageStatsConsent GetUsageStatsConsent() override; |
156 | 156 |
157 private: | 157 private: |
158 DISALLOW_COPY_AND_ASSIGN(MockDaemonControllerDelegate); | 158 DISALLOW_COPY_AND_ASSIGN(MockDaemonControllerDelegate); |
159 }; | 159 }; |
160 | 160 |
161 MockDaemonControllerDelegate::MockDaemonControllerDelegate() {} | 161 MockDaemonControllerDelegate::MockDaemonControllerDelegate() {} |
162 | 162 |
163 MockDaemonControllerDelegate::~MockDaemonControllerDelegate() {} | 163 MockDaemonControllerDelegate::~MockDaemonControllerDelegate() {} |
164 | 164 |
165 DaemonController::State MockDaemonControllerDelegate::GetState() { | 165 DaemonController::State MockDaemonControllerDelegate::GetState() { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 consent.allowed = true; | 219 consent.allowed = true; |
220 consent.set_by_policy = true; | 220 consent.set_by_policy = true; |
221 return consent; | 221 return consent; |
222 } | 222 } |
223 | 223 |
224 class Me2MeNativeMessagingHostTest : public testing::Test { | 224 class Me2MeNativeMessagingHostTest : public testing::Test { |
225 public: | 225 public: |
226 Me2MeNativeMessagingHostTest(); | 226 Me2MeNativeMessagingHostTest(); |
227 virtual ~Me2MeNativeMessagingHostTest(); | 227 virtual ~Me2MeNativeMessagingHostTest(); |
228 | 228 |
229 virtual void SetUp() OVERRIDE; | 229 virtual void SetUp() override; |
230 virtual void TearDown() OVERRIDE; | 230 virtual void TearDown() override; |
231 | 231 |
232 scoped_ptr<base::DictionaryValue> ReadMessageFromOutputPipe(); | 232 scoped_ptr<base::DictionaryValue> ReadMessageFromOutputPipe(); |
233 | 233 |
234 void WriteMessageToInputPipe(const base::Value& message); | 234 void WriteMessageToInputPipe(const base::Value& message); |
235 | 235 |
236 // The Host process should shut down when it receives a malformed request. | 236 // The Host process should shut down when it receives a malformed request. |
237 // This is tested by sending a known-good request, followed by |message|, | 237 // This is tested by sending a known-good request, followed by |message|, |
238 // followed by the known-good request again. The response file should only | 238 // followed by the known-good request again. The response file should only |
239 // contain a single response from the first good request. | 239 // contain a single response from the first good request. |
240 void TestBadRequest(const base::Value& message); | 240 void TestBadRequest(const base::Value& message); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 | 592 |
593 // Verify rejection if startDaemon request has no "consent" parameter. | 593 // Verify rejection if startDaemon request has no "consent" parameter. |
594 TEST_F(Me2MeNativeMessagingHostTest, StartDaemonNoConsent) { | 594 TEST_F(Me2MeNativeMessagingHostTest, StartDaemonNoConsent) { |
595 base::DictionaryValue message; | 595 base::DictionaryValue message; |
596 message.SetString("type", "startDaemon"); | 596 message.SetString("type", "startDaemon"); |
597 message.Set("config", base::DictionaryValue().DeepCopy()); | 597 message.Set("config", base::DictionaryValue().DeepCopy()); |
598 TestBadRequest(message); | 598 TestBadRequest(message); |
599 } | 599 } |
600 | 600 |
601 } // namespace remoting | 601 } // namespace remoting |
OLD | NEW |