Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: remoting/host/it2me/it2me_native_messaging_host_unittest.cc

Issue 2847853003: Remove policy watching from It2MeHost. (Closed)
Patch Set: Fix unit tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..45b9af4b25099c2704fc21c5014bbb00882c6084 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),
@@ -229,8 +227,7 @@ scoped_refptr<It2MeHost> MockIt2MeHostFactory::CreateIt2MeHost(
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 +396,16 @@ void It2MeNativeMessagingHostTest::VerifyErrorResponse() {
void It2MeNativeMessagingHostTest::VerifyConnectResponses(int request_id) {
bool connect_response_received = false;
+ bool nat_policy_received = false;
rkjnsn 2017/05/03 21:31:47 I see this was added to fix the unit test, but I c
Jamie 2017/05/03 23:41:10 The change to the native messaging host means that
rkjnsn 2017/05/04 20:45:45 Ah, I see. Since MockIt2MeHost overrides Connect,
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 +417,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));
@@ -609,7 +611,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.

Powered by Google App Engine
This is Rietveld 408576698