| Index: components/arc/arc_bridge_service_unittest.cc
|
| diff --git a/components/arc/arc_bridge_service_unittest.cc b/components/arc/arc_bridge_service_unittest.cc
|
| index 598e54b058fc7b4fa798f2015d0e571fadc0eb19..502d75593ea3d72322658b75b5e6f1c4e2d3f267 100644
|
| --- a/components/arc/arc_bridge_service_unittest.cc
|
| +++ b/components/arc/arc_bridge_service_unittest.cc
|
| @@ -41,12 +41,17 @@ class ArcBridgeTest : public testing::Test, public ArcBridgeService::Observer {
|
| }
|
| }
|
|
|
| + void OnBridgeStopped(ArcBridgeService::StopReason stop_reason) override {
|
| + stop_reason_ = stop_reason;
|
| + }
|
| +
|
| bool ready() const { return ready_; }
|
| ArcBridgeService::State state() const { return state_; }
|
|
|
| protected:
|
| std::unique_ptr<ArcBridgeServiceImpl> service_;
|
| std::unique_ptr<FakeArcBridgeInstance> instance_;
|
| + ArcBridgeService::StopReason stop_reason_;
|
|
|
| private:
|
| void SetUp() override {
|
| @@ -54,6 +59,7 @@ class ArcBridgeTest : public testing::Test, public ArcBridgeService::Observer {
|
|
|
| ready_ = false;
|
| state_ = ArcBridgeService::State::STOPPED;
|
| + stop_reason_ = ArcBridgeService::StopReason::NO_ERROR;
|
|
|
| instance_.reset(new FakeArcBridgeInstance());
|
| service_.reset(new ArcBridgeServiceImpl(
|
| @@ -135,7 +141,7 @@ TEST_F(ArcBridgeTest, Restart) {
|
| // Simulate a connection loss.
|
| service_->DisableReconnectDelayForTesting();
|
| service_->OnChannelClosed();
|
| - instance_->SimulateCrash();
|
| + instance_->SimulateCrash(ArcBridgeService::StopReason::CRASH);
|
| instance_->WaitForInitCall();
|
| ASSERT_EQ(ArcBridgeService::State::READY, state());
|
| ASSERT_EQ(2, instance_->init_calls());
|
| @@ -144,6 +150,46 @@ TEST_F(ArcBridgeTest, Restart) {
|
| ASSERT_EQ(ArcBridgeService::State::STOPPED, state());
|
| }
|
|
|
| +TEST_F(ArcBridgeTest, BootFailure) {
|
| + ASSERT_FALSE(ready());
|
| +
|
| + service_->SetAvailable(true);
|
| + service_->HandleStartup();
|
| + instance_->WaitForInitCall();
|
| + ASSERT_EQ(ArcBridgeService::State::READY, state());
|
| +
|
| + // Simulate boot failure.
|
| + service_->DisableReconnectDelayForTesting();
|
| + service_->OnChannelClosed();
|
| + instance_->SimulateCrash(ArcBridgeService::StopReason::GENERIC_BOOT_FAILURE);
|
| + instance_->WaitForInitCall();
|
| +
|
| + ASSERT_EQ(ArcBridgeService::StopReason::GENERIC_BOOT_FAILURE, stop_reason_);
|
| +
|
| + service_->Shutdown();
|
| + ASSERT_EQ(ArcBridgeService::State::STOPPED, state());
|
| +}
|
| +
|
| +TEST_F(ArcBridgeTest, Crash) {
|
| + ASSERT_FALSE(ready());
|
| +
|
| + service_->SetAvailable(true);
|
| + service_->HandleStartup();
|
| + instance_->WaitForInitCall();
|
| + ASSERT_EQ(ArcBridgeService::State::READY, state());
|
| +
|
| + // Simulate crash.
|
| + service_->DisableReconnectDelayForTesting();
|
| + service_->OnChannelClosed();
|
| + instance_->SimulateCrash(ArcBridgeService::StopReason::CRASH);
|
| + instance_->WaitForInitCall();
|
| +
|
| + ASSERT_EQ(ArcBridgeService::StopReason::CRASH, stop_reason_);
|
| +
|
| + service_->Shutdown();
|
| + ASSERT_EQ(ArcBridgeService::State::STOPPED, state());
|
| +}
|
| +
|
| // Removing the same observer more than once should be okay.
|
| TEST_F(ArcBridgeTest, RemoveObserverTwice) {
|
| ASSERT_FALSE(ready());
|
|
|