src/base/fuchsia/scoped_service_binding_unittest.cc
TEST_F(ScopedServiceBindingTest, SingleClientPreferExisting) {
  // Teardown the default multi-client binding and create a prefer-existing one.
  service_binding_ = nullptr;
  ScopedSingleClientServiceBinding<testfidl::TestInterface,
                                   ScopedServiceBindingPolicy::kPreferExisting>
      binding(outgoing_directory_.get(), &test_service_);

  // Connect the first client, and verify that it is functional.
  auto existing_client =
      public_service_directory_->Connect<testfidl::TestInterface>();
  VerifyTestInterface(&existing_client, ZX_OK);

  // Connect the second client, then verify that the it gets closed and the
  // existing one remains functional.
  auto new_client =
      public_service_directory_->Connect<testfidl::TestInterface>();
  RunLoop().RunUntilIdle();
  EXPECT_FALSE(new_client);
  VerifyTestInterface(&existing_client, ZX_OK);
}
// Verify that if we connect twice to a prefer-existing bound service, the new
// connection gets closed.
Verify that if we connect twice to a prefer-existing bound service, the new
connection gets closed.
Verify that if we connect twice to a prefer - existing bound service the new connection gets closed .
TEST_F(ScopedServiceBindingTest, SingleClientPreferExisting) {
  service_binding_ = nullptr;
  ScopedSingleClientServiceBinding<testfidl::TestInterface,
                                   ScopedServiceBindingPolicy::kPreferExisting>
      binding(outgoing_directory_.get(), &test_service_);
  auto existing_client =
      public_service_directory_->Connect<testfidl::TestInterface>();
  VerifyTestInterface(&existing_client, ZX_OK);
  auto new_client =
      public_service_directory_->Connect<testfidl::TestInterface>();
  RunLoop().RunUntilIdle();
  EXPECT_FALSE(new_client);
  VerifyTestInterface(&existing_client, ZX_OK);
}
TEST_F ( ScopedServiceBindingTest , SingleClientPreferExisting ) { service_binding_ = nullptr ; ScopedSingleClientServiceBinding < testfidl :: TestInterface , ScopedServiceBindingPolicy :: kPreferExisting > binding ( outgoing_directory_ . get ( ) , & test_service_ ) ; auto existing_client = public_service_directory_ -> Connect < testfidl :: TestInterface > ( ) ; VerifyTestInterface ( & existing_client , ZX_OK ) ; auto new_client = public_service_directory_ -> Connect < testfidl :: TestInterface > ( ) ; RunLoop ( ) . RunUntilIdle ( ) ; EXPECT_FALSE ( new_client ) ; VerifyTestInterface ( & existing_client , ZX_OK ) ; }
Verify that if we connect twice to a prefer-existing bound service, the new
connection gets closed.
Verify that if we connect twice to a prefer - existing bound service the new connection gets closed .
// Teardown the default multi-client binding and create a prefer-existing one. // Connect the first client, and verify that it is functional. // Connect the second client, then verify that the it gets closed and the // existing one remains functional.