OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 StopReason::GENERIC_BOOT_FAILURE)); | 148 StopReason::GENERIC_BOOT_FAILURE)); |
149 EXPECT_TRUE(arc_bridge_service()->stopped()); | 149 EXPECT_TRUE(arc_bridge_service()->stopped()); |
150 | 150 |
151 arc_bridge_service()->RequestStart(); | 151 arc_bridge_service()->RequestStart(); |
152 EXPECT_EQ(StopReason::GENERIC_BOOT_FAILURE, stop_reason()); | 152 EXPECT_EQ(StopReason::GENERIC_BOOT_FAILURE, stop_reason()); |
153 EXPECT_TRUE(arc_bridge_service()->stopped()); | 153 EXPECT_TRUE(arc_bridge_service()->stopped()); |
154 } | 154 } |
155 | 155 |
156 // If the instance is stopped, it should be re-started. | 156 // If the instance is stopped, it should be re-started. |
157 TEST_F(ArcBridgeTest, Restart) { | 157 TEST_F(ArcBridgeTest, Restart) { |
158 arc_bridge_service()->DisableReconnectDelayForTesting(); | 158 arc_bridge_service()->SetRestartDelayForTesting(base::TimeDelta()); |
159 EXPECT_TRUE(arc_bridge_service()->stopped()); | 159 EXPECT_TRUE(arc_bridge_service()->stopped()); |
160 | 160 |
161 arc_bridge_service()->RequestStart(); | 161 arc_bridge_service()->RequestStart(); |
162 EXPECT_TRUE(arc_bridge_service()->ready()); | 162 EXPECT_TRUE(arc_bridge_service()->ready()); |
163 | 163 |
164 // Simulate a connection loss. | 164 // Simulate a connection loss. |
165 ASSERT_TRUE(arc_session()); | 165 ASSERT_TRUE(arc_session()); |
166 arc_session()->StopWithReason(StopReason::CRASH); | 166 arc_session()->StopWithReason(StopReason::CRASH); |
| 167 EXPECT_TRUE(arc_bridge_service()->stopped()); |
| 168 base::RunLoop().RunUntilIdle(); |
167 EXPECT_TRUE(arc_bridge_service()->ready()); | 169 EXPECT_TRUE(arc_bridge_service()->ready()); |
168 | 170 |
169 arc_bridge_service()->RequestStop(); | 171 arc_bridge_service()->RequestStop(); |
170 EXPECT_TRUE(arc_bridge_service()->stopped()); | 172 EXPECT_TRUE(arc_bridge_service()->stopped()); |
171 } | 173 } |
172 | 174 |
173 // Makes sure OnSessionStopped is called on stop. | 175 // Makes sure OnSessionStopped is called on stop. |
174 TEST_F(ArcBridgeTest, OnSessionStopped) { | 176 TEST_F(ArcBridgeTest, OnSessionStopped) { |
175 arc_bridge_service()->DisableReconnectDelayForTesting(); | 177 arc_bridge_service()->SetRestartDelayForTesting(base::TimeDelta()); |
176 EXPECT_TRUE(arc_bridge_service()->stopped()); | 178 EXPECT_TRUE(arc_bridge_service()->stopped()); |
177 | 179 |
178 arc_bridge_service()->RequestStart(); | 180 arc_bridge_service()->RequestStart(); |
179 EXPECT_TRUE(arc_bridge_service()->ready()); | 181 EXPECT_TRUE(arc_bridge_service()->ready()); |
180 | 182 |
181 // Simulate boot failure. | 183 // Simulate boot failure. |
182 ASSERT_TRUE(arc_session()); | 184 ASSERT_TRUE(arc_session()); |
183 arc_session()->StopWithReason(StopReason::GENERIC_BOOT_FAILURE); | 185 arc_session()->StopWithReason(StopReason::GENERIC_BOOT_FAILURE); |
184 EXPECT_EQ(StopReason::GENERIC_BOOT_FAILURE, stop_reason()); | 186 EXPECT_EQ(StopReason::GENERIC_BOOT_FAILURE, stop_reason()); |
| 187 EXPECT_TRUE(arc_bridge_service()->stopped()); |
| 188 base::RunLoop().RunUntilIdle(); |
185 EXPECT_TRUE(arc_bridge_service()->ready()); | 189 EXPECT_TRUE(arc_bridge_service()->ready()); |
186 | 190 |
187 // Simulate crash. | 191 // Simulate crash. |
188 ASSERT_TRUE(arc_session()); | 192 ASSERT_TRUE(arc_session()); |
189 arc_session()->StopWithReason(StopReason::CRASH); | 193 arc_session()->StopWithReason(StopReason::CRASH); |
190 EXPECT_EQ(StopReason::CRASH, stop_reason()); | 194 EXPECT_EQ(StopReason::CRASH, stop_reason()); |
| 195 EXPECT_TRUE(arc_bridge_service()->stopped()); |
| 196 base::RunLoop().RunUntilIdle(); |
191 EXPECT_TRUE(arc_bridge_service()->ready()); | 197 EXPECT_TRUE(arc_bridge_service()->ready()); |
192 | 198 |
193 // Graceful stop. | 199 // Graceful stop. |
194 arc_bridge_service()->RequestStop(); | 200 arc_bridge_service()->RequestStop(); |
195 EXPECT_EQ(StopReason::SHUTDOWN, stop_reason()); | 201 EXPECT_EQ(StopReason::SHUTDOWN, stop_reason()); |
196 EXPECT_TRUE(arc_bridge_service()->stopped()); | 202 EXPECT_TRUE(arc_bridge_service()->stopped()); |
197 } | 203 } |
198 | 204 |
199 TEST_F(ArcBridgeTest, Shutdown) { | 205 TEST_F(ArcBridgeTest, Shutdown) { |
200 arc_bridge_service()->DisableReconnectDelayForTesting(); | 206 arc_bridge_service()->SetRestartDelayForTesting(base::TimeDelta()); |
201 EXPECT_TRUE(arc_bridge_service()->stopped()); | 207 EXPECT_TRUE(arc_bridge_service()->stopped()); |
202 | 208 |
203 arc_bridge_service()->RequestStart(); | 209 arc_bridge_service()->RequestStart(); |
204 EXPECT_TRUE(arc_bridge_service()->ready()); | 210 EXPECT_TRUE(arc_bridge_service()->ready()); |
205 | 211 |
206 // Simulate shutdown. | 212 // Simulate shutdown. |
207 arc_bridge_service()->OnShutdown(); | 213 arc_bridge_service()->OnShutdown(); |
208 EXPECT_EQ(StopReason::SHUTDOWN, stop_reason()); | 214 EXPECT_EQ(StopReason::SHUTDOWN, stop_reason()); |
209 EXPECT_TRUE(arc_bridge_service()->stopped()); | 215 EXPECT_TRUE(arc_bridge_service()->stopped()); |
210 } | 216 } |
(...skipping 11 matching lines...) Expand all Loading... |
222 | 228 |
223 // Removing an unknown observer should be allowed. | 229 // Removing an unknown observer should be allowed. |
224 TEST_F(ArcBridgeTest, RemoveUnknownObserver) { | 230 TEST_F(ArcBridgeTest, RemoveUnknownObserver) { |
225 EXPECT_TRUE(arc_bridge_service()->stopped()); | 231 EXPECT_TRUE(arc_bridge_service()->stopped()); |
226 | 232 |
227 DummyObserver dummy_observer; | 233 DummyObserver dummy_observer; |
228 arc_bridge_service()->RemoveObserver(&dummy_observer); | 234 arc_bridge_service()->RemoveObserver(&dummy_observer); |
229 } | 235 } |
230 | 236 |
231 } // namespace arc | 237 } // namespace arc |
OLD | NEW |