OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/message_loop_proxy.h" | 6 #include "base/message_loop_proxy.h" |
7 #include "remoting/jingle_glue/mock_objects.h" | 7 #include "remoting/jingle_glue/mock_objects.h" |
8 #include "remoting/host/log_to_server.h" | 8 #include "remoting/host/log_to_server.h" |
9 #include "testing/gmock_mutant.h" | 9 #include "testing/gmock_mutant.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 .WillRepeatedly(Return("host@domain.com/1234")); | 51 .WillRepeatedly(Return("host@domain.com/1234")); |
52 EXPECT_CALL(signal_strategy_, AddListener(_)); | 52 EXPECT_CALL(signal_strategy_, AddListener(_)); |
53 EXPECT_CALL(signal_strategy_, GetNextId()); | 53 EXPECT_CALL(signal_strategy_, GetNextId()); |
54 EXPECT_CALL(signal_strategy_, SendStanzaPtr(_)) | 54 EXPECT_CALL(signal_strategy_, SendStanzaPtr(_)) |
55 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); | 55 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); |
56 EXPECT_CALL(signal_strategy_, RemoveListener(_)) | 56 EXPECT_CALL(signal_strategy_, RemoveListener(_)) |
57 .WillOnce(QuitMainMessageLoop(&message_loop_)) | 57 .WillOnce(QuitMainMessageLoop(&message_loop_)) |
58 .RetiresOnSaturation(); | 58 .RetiresOnSaturation(); |
59 } | 59 } |
60 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::CONNECTED); | 60 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::CONNECTED); |
| 61 protocol::TransportRoute route; |
| 62 route.type = protocol::TransportRoute::DIRECT; |
| 63 log_to_server_->OnClientRouteChange("client@domain.com/5678", "video", route); |
61 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); | 64 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); |
62 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::DISCONNECTED); | 65 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::DISCONNECTED); |
63 message_loop_.Run(); | 66 message_loop_.Run(); |
64 } | 67 } |
65 | 68 |
66 TEST_F(LogToServerTest, SendLater) { | 69 TEST_F(LogToServerTest, SendLater) { |
| 70 protocol::TransportRoute route; |
| 71 route.type = protocol::TransportRoute::DIRECT; |
| 72 log_to_server_->OnClientRouteChange("client@domain.com/5678", "video", route); |
67 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); | 73 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); |
68 { | 74 { |
69 InSequence s; | 75 InSequence s; |
70 EXPECT_CALL(signal_strategy_, GetLocalJid()) | 76 EXPECT_CALL(signal_strategy_, GetLocalJid()) |
71 .WillRepeatedly(Return("host@domain.com/1234")); | 77 .WillRepeatedly(Return("host@domain.com/1234")); |
72 EXPECT_CALL(signal_strategy_, AddListener(_)); | 78 EXPECT_CALL(signal_strategy_, AddListener(_)); |
73 EXPECT_CALL(signal_strategy_, GetNextId()); | 79 EXPECT_CALL(signal_strategy_, GetNextId()); |
74 EXPECT_CALL(signal_strategy_, SendStanzaPtr(_)) | 80 EXPECT_CALL(signal_strategy_, SendStanzaPtr(_)) |
75 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); | 81 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); |
76 EXPECT_CALL(signal_strategy_, RemoveListener(_)) | 82 EXPECT_CALL(signal_strategy_, RemoveListener(_)) |
77 .WillOnce(QuitMainMessageLoop(&message_loop_)) | 83 .WillOnce(QuitMainMessageLoop(&message_loop_)) |
78 .RetiresOnSaturation(); | 84 .RetiresOnSaturation(); |
79 } | 85 } |
80 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::CONNECTED); | 86 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::CONNECTED); |
81 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::DISCONNECTED); | 87 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::DISCONNECTED); |
82 message_loop_.Run(); | 88 message_loop_.Run(); |
83 } | 89 } |
84 | 90 |
85 TEST_F(LogToServerTest, SendTwoEntriesLater) { | 91 TEST_F(LogToServerTest, SendTwoEntriesLater) { |
| 92 protocol::TransportRoute route; |
| 93 route.type = protocol::TransportRoute::DIRECT; |
| 94 log_to_server_->OnClientRouteChange("client@domain.com/5678", "video", route); |
86 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); | 95 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); |
87 log_to_server_->OnClientAuthenticated("client2@domain.com/6789"); | 96 log_to_server_->OnClientAuthenticated("client2@domain.com/6789"); |
88 { | 97 { |
89 InSequence s; | 98 InSequence s; |
90 EXPECT_CALL(signal_strategy_, GetLocalJid()) | 99 EXPECT_CALL(signal_strategy_, GetLocalJid()) |
91 .WillRepeatedly(Return("host@domain.com/1234")); | 100 .WillRepeatedly(Return("host@domain.com/1234")); |
92 EXPECT_CALL(signal_strategy_, AddListener(_)); | 101 EXPECT_CALL(signal_strategy_, AddListener(_)); |
93 EXPECT_CALL(signal_strategy_, GetNextId()); | 102 EXPECT_CALL(signal_strategy_, GetNextId()); |
94 EXPECT_CALL(signal_strategy_, SendStanzaPtr(_)) | 103 EXPECT_CALL(signal_strategy_, SendStanzaPtr(_)) |
95 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); | 104 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); |
96 EXPECT_CALL(signal_strategy_, RemoveListener(_)) | 105 EXPECT_CALL(signal_strategy_, RemoveListener(_)) |
97 .WillOnce(QuitMainMessageLoop(&message_loop_)) | 106 .WillOnce(QuitMainMessageLoop(&message_loop_)) |
98 .RetiresOnSaturation(); | 107 .RetiresOnSaturation(); |
99 } | 108 } |
100 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::CONNECTED); | 109 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::CONNECTED); |
101 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::DISCONNECTED); | 110 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::DISCONNECTED); |
102 message_loop_.Run(); | 111 message_loop_.Run(); |
103 } | 112 } |
104 | 113 |
105 } // namespace remoting | 114 } // namespace remoting |
OLD | NEW |