Chromium Code Reviews| Index: remoting/host/it2me/it2me_native_messaging_host_unittest.cc |
| diff --git a/remoting/host/it2me/it2me_native_messaging_host_unittest.cc b/remoting/host/it2me/it2me_native_messaging_host_unittest.cc |
| index 072bfb6d2a8ce15b36559c4b8b33b92b0d30f74b..52f07a0590d4a7b060137affd749fff35b5c77a5 100644 |
| --- a/remoting/host/it2me/it2me_native_messaging_host_unittest.cc |
| +++ b/remoting/host/it2me/it2me_native_messaging_host_unittest.cc |
| @@ -125,13 +125,11 @@ void FakePolicyService::RefreshPolicies(const base::Closure& callback) { |
| class MockIt2MeHost : public It2MeHost { |
| public: |
| MockIt2MeHost(std::unique_ptr<ChromotingHostContext> context, |
| - std::unique_ptr<PolicyWatcher> policy_watcher, |
| base::WeakPtr<It2MeHost::Observer> observer, |
| std::unique_ptr<SignalStrategy> signal_strategy, |
| const std::string& username, |
| const std::string& directory_bot_jid) |
| : It2MeHost(std::move(context), |
| - std::move(policy_watcher), |
| /*confirmation_dialog_factory=*/nullptr, |
| observer, |
| std::move(signal_strategy), |
| @@ -208,7 +206,6 @@ class MockIt2MeHostFactory : public It2MeHostFactory { |
| scoped_refptr<It2MeHost> CreateIt2MeHost( |
| std::unique_ptr<ChromotingHostContext> context, |
| - policy::PolicyService* policy_service, |
| base::WeakPtr<It2MeHost::Observer> observer, |
| std::unique_ptr<SignalStrategy> signal_strategy, |
| const std::string& username, |
| @@ -224,13 +221,11 @@ MockIt2MeHostFactory::~MockIt2MeHostFactory() {} |
| scoped_refptr<It2MeHost> MockIt2MeHostFactory::CreateIt2MeHost( |
| std::unique_ptr<ChromotingHostContext> context, |
| - policy::PolicyService* policy_service, |
| base::WeakPtr<It2MeHost::Observer> observer, |
| std::unique_ptr<SignalStrategy> signal_strategy, |
| const std::string& username, |
| const std::string& directory_bot_jid) { |
| - return new MockIt2MeHost(std::move(context), |
| - /*policy_watcher=*/nullptr, observer, |
| + return new MockIt2MeHost(std::move(context), observer, |
| std::move(signal_strategy), username, |
| directory_bot_jid); |
| } |
| @@ -399,14 +394,16 @@ void It2MeNativeMessagingHostTest::VerifyErrorResponse() { |
| void It2MeNativeMessagingHostTest::VerifyConnectResponses(int request_id) { |
| bool connect_response_received = false; |
| + bool nat_policy_received = false; |
| bool starting_received = false; |
| bool requestedAccessCode_received = false; |
| bool receivedAccessCode_received = false; |
| bool connecting_received = false; |
| bool connected_received = false; |
| - // We expect a total of 6 messages: 1 connectResponse and 5 hostStateChanged. |
| - for (int i = 0; i < 6; ++i) { |
| + // We expect a total of 7 messages: 1 connectResponse, 1 natPolicyChanged, |
| + // and 5 hostStateChanged. |
| + for (int i = 0; i < 7; ++i) { |
| std::unique_ptr<base::DictionaryValue> response = |
| ReadMessageFromOutputPipe(); |
| ASSERT_TRUE(response); |
| @@ -418,6 +415,9 @@ void It2MeNativeMessagingHostTest::VerifyConnectResponses(int request_id) { |
| EXPECT_FALSE(connect_response_received); |
| connect_response_received = true; |
| VerifyId(std::move(response), request_id); |
| + } else if (type == "natPolicyChanged") { |
| + EXPECT_FALSE(nat_policy_received); |
| + nat_policy_received = true; |
| } else if (type == "hostStateChanged") { |
| std::string state; |
| ASSERT_TRUE(response->GetString("state", &state)); |
| @@ -530,11 +530,14 @@ void It2MeNativeMessagingHostTest::StartHost() { |
| std::move(output_write_file))); |
| // Creating a native messaging host with a mock It2MeHostFactory. |
| + std::unique_ptr<ChromotingHostContext> context = |
| + ChromotingHostContext::Create(host_task_runner_); |
| + std::unique_ptr<PolicyWatcher> policy_watcher = PolicyWatcher::Create( |
| + fake_policy_service_.get(), context->file_task_runner()); |
|
rkjnsn
2017/05/04 22:52:40
This will still create a PolicyWatcher that reads
Jamie
2017/05/04 23:08:40
Done (it let me delete FakePolicyService entirely,
|
| std::unique_ptr<extensions::NativeMessageHost> it2me_host( |
| new It2MeNativeMessagingHost( |
| - /*needs_elevation=*/false, fake_policy_service_.get(), |
| - ChromotingHostContext::Create(host_task_runner_), |
| - base::WrapUnique(new MockIt2MeHostFactory()))); |
| + /*needs_elevation=*/false, std::move(policy_watcher), |
| + std::move(context), base::WrapUnique(new MockIt2MeHostFactory()))); |
| it2me_host->Start(pipe_.get()); |
| pipe_->Start(std::move(it2me_host), std::move(channel)); |
| @@ -609,7 +612,7 @@ TEST_F(It2MeNativeMessagingHostTest, Id) { |
| EXPECT_EQ("42", value); |
| } |
| -TEST_F(It2MeNativeMessagingHostTest, Connect) { |
| +TEST_F(It2MeNativeMessagingHostTest, ConnectMultiple) { |
| // A new It2MeHost instance is created for every it2me session. The native |
| // messaging host, on the other hand, is long lived. This test verifies |
| // multiple It2Me host startup and shutdowns. |