Chromium Code Reviews| 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/native_messaging_host.h" | 5 #include "remoting/host/setup/native_messaging_host.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 EXPECT_TRUE(supported); | 78 EXPECT_TRUE(supported); |
| 79 EXPECT_TRUE(allowed); | 79 EXPECT_TRUE(allowed); |
| 80 EXPECT_TRUE(set_by_policy); | 80 EXPECT_TRUE(set_by_policy); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void VerifyStopDaemonResponse(const base::DictionaryValue* response) { | 83 void VerifyStopDaemonResponse(const base::DictionaryValue* response) { |
| 84 ASSERT_TRUE(response); | 84 ASSERT_TRUE(response); |
| 85 std::string value; | 85 std::string value; |
| 86 EXPECT_TRUE(response->GetString("type", &value)); | 86 EXPECT_TRUE(response->GetString("type", &value)); |
| 87 EXPECT_EQ("stopDaemonResponse", value); | 87 EXPECT_EQ("stopDaemonResponse", value); |
| 88 int result; | 88 EXPECT_TRUE(response->GetString("result", &value)); |
| 89 EXPECT_TRUE(response->GetInteger("result", &result)); | 89 EXPECT_EQ(remoting::NativeMessagingHost::kResultOk, value); |
|
Sergey Ulanov
2013/05/31 23:01:43
I'd rather not bother about sharing constants with
Lambros
2013/06/03 21:28:44
Done.
| |
| 90 EXPECT_EQ(0, result); | |
| 91 } | 90 } |
| 92 | 91 |
| 93 void VerifyGetDaemonStateResponse(const base::DictionaryValue* response) { | 92 void VerifyGetDaemonStateResponse(const base::DictionaryValue* response) { |
| 94 ASSERT_TRUE(response); | 93 ASSERT_TRUE(response); |
| 95 std::string value; | 94 std::string value; |
| 96 EXPECT_TRUE(response->GetString("type", &value)); | 95 EXPECT_TRUE(response->GetString("type", &value)); |
| 97 EXPECT_EQ("getDaemonStateResponse", value); | 96 EXPECT_EQ("getDaemonStateResponse", value); |
| 98 int result; | 97 EXPECT_TRUE(response->GetString("state", &value)); |
| 99 EXPECT_TRUE(response->GetInteger("state", &result)); | 98 EXPECT_EQ(remoting::NativeMessagingHost::kStateStarted, value); |
| 100 EXPECT_EQ(4, result); | |
| 101 } | 99 } |
| 102 | 100 |
| 103 void VerifyUpdateDaemonConfigResponse(const base::DictionaryValue* response) { | 101 void VerifyUpdateDaemonConfigResponse(const base::DictionaryValue* response) { |
| 104 ASSERT_TRUE(response); | 102 ASSERT_TRUE(response); |
| 105 std::string value; | 103 std::string value; |
| 106 EXPECT_TRUE(response->GetString("type", &value)); | 104 EXPECT_TRUE(response->GetString("type", &value)); |
| 107 EXPECT_EQ("updateDaemonConfigResponse", value); | 105 EXPECT_EQ("updateDaemonConfigResponse", value); |
| 108 int result; | 106 EXPECT_TRUE(response->GetString("result", &value)); |
| 109 EXPECT_TRUE(response->GetInteger("result", &result)); | 107 EXPECT_EQ(remoting::NativeMessagingHost::kResultOk, value); |
| 110 EXPECT_EQ(0, result); | |
| 111 } | 108 } |
| 112 | 109 |
| 113 void VerifyStartDaemonResponse(const base::DictionaryValue* response) { | 110 void VerifyStartDaemonResponse(const base::DictionaryValue* response) { |
| 114 ASSERT_TRUE(response); | 111 ASSERT_TRUE(response); |
| 115 std::string value; | 112 std::string value; |
| 116 EXPECT_TRUE(response->GetString("type", &value)); | 113 EXPECT_TRUE(response->GetString("type", &value)); |
| 117 EXPECT_EQ("startDaemonResponse", value); | 114 EXPECT_EQ("startDaemonResponse", value); |
| 118 int result; | 115 EXPECT_TRUE(response->GetString("result", &value)); |
| 119 EXPECT_TRUE(response->GetInteger("result", &result)); | 116 EXPECT_EQ(remoting::NativeMessagingHost::kResultOk, value); |
| 120 EXPECT_EQ(0, result); | |
| 121 } | 117 } |
| 122 | 118 |
| 123 } // namespace | 119 } // namespace |
| 124 | 120 |
| 125 namespace remoting { | 121 namespace remoting { |
| 126 | 122 |
| 127 class MockDaemonController : public DaemonController { | 123 class MockDaemonController : public DaemonController { |
| 128 public: | 124 public: |
| 129 MockDaemonController(); | 125 MockDaemonController(); |
| 130 virtual ~MockDaemonController(); | 126 virtual ~MockDaemonController(); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 | 504 |
| 509 // Verify rejection if startDaemon request has no "consent" parameter. | 505 // Verify rejection if startDaemon request has no "consent" parameter. |
| 510 TEST_F(NativeMessagingHostTest, StartDaemonNoConsent) { | 506 TEST_F(NativeMessagingHostTest, StartDaemonNoConsent) { |
| 511 base::DictionaryValue message; | 507 base::DictionaryValue message; |
| 512 message.SetString("type", "startDaemon"); | 508 message.SetString("type", "startDaemon"); |
| 513 message.Set("config", base::DictionaryValue().DeepCopy()); | 509 message.Set("config", base::DictionaryValue().DeepCopy()); |
| 514 TestBadRequest(message); | 510 TestBadRequest(message); |
| 515 } | 511 } |
| 516 | 512 |
| 517 } // namespace remoting | 513 } // namespace remoting |
| OLD | NEW |