@@ -368,9 +368,8 @@ class TetherServiceTest : public chromeos::NetworkStateTest {
368
368
chromeos::multidevice_setup::MultiDeviceSetupClientImpl::Factory::
369
369
SetInstanceForTesting (
370
370
fake_multidevice_setup_client_impl_factory_.get ());
371
- initial_host_status_ =
372
- chromeos::multidevice_setup::mojom::HostStatus::kHostVerified ;
373
- initial_host_device_ = test_devices_[0 ];
371
+ initial_feature_state_ =
372
+ chromeos::multidevice_setup::mojom::FeatureState::kEnabledByUser ;
374
373
375
374
fake_cryptauth_service_ =
376
375
std::make_unique<cryptauth::FakeCryptAuthService>();
@@ -453,8 +452,9 @@ class TetherServiceTest : public chromeos::NetworkStateTest {
453
452
}
454
453
455
454
void CreateTetherService () {
456
- fake_multidevice_setup_client_->SetHostStatusWithDevice (
457
- std::make_pair (initial_host_status_, initial_host_device_));
455
+ fake_multidevice_setup_client_->SetFeatureState (
456
+ chromeos::multidevice_setup::mojom::Feature::kInstantTethering ,
457
+ initial_feature_state_);
458
458
459
459
tether_service_ = base::WrapUnique (new TestTetherService (
460
460
profile_.get (), fake_power_manager_client_.get (),
@@ -589,8 +589,7 @@ class TetherServiceTest : public chromeos::NetworkStateTest {
589
589
std::unique_ptr<cryptauth::FakeCryptAuthEnrollmentManager>
590
590
fake_enrollment_manager_;
591
591
592
- chromeos::multidevice_setup::mojom::HostStatus initial_host_status_;
593
- base::Optional<cryptauth::RemoteDeviceRef> initial_host_device_;
592
+ chromeos::multidevice_setup::mojom::FeatureState initial_feature_state_;
594
593
595
594
scoped_refptr<MockExtendedBluetoothAdapter> mock_adapter_;
596
595
bool is_adapter_present_;
@@ -723,9 +722,8 @@ TEST_F(TetherServiceTest,
723
722
kEnableUnifiedMultiDeviceSetup } /* enabled_features */ ,
724
723
{} /* disabled_features */ );
725
724
726
- initial_host_status_ =
727
- chromeos::multidevice_setup::mojom::HostStatus::kNoEligibleHosts ;
728
- initial_host_device_ = base::nullopt;
725
+ initial_feature_state_ = chromeos::multidevice_setup::mojom::FeatureState::
726
+ kUnavailableNoVerifiedHost ;
729
727
730
728
CreateTetherService ();
731
729
@@ -735,10 +733,9 @@ TEST_F(TetherServiceTest,
735
733
chromeos::NetworkTypePattern::Tether ()));
736
734
VerifyTetherActiveStatus (false /* expected_active */ );
737
735
738
- fake_multidevice_setup_client_->SetHostStatusWithDevice (std::make_pair (
739
- chromeos::multidevice_setup::mojom::HostStatus::kHostVerified ,
740
- test_devices_[0 ]));
741
- base::RunLoop ().RunUntilIdle ();
736
+ fake_multidevice_setup_client_->SetFeatureState (
737
+ chromeos::multidevice_setup::mojom::Feature::kInstantTethering ,
738
+ chromeos::multidevice_setup::mojom::FeatureState::kEnabledByUser );
742
739
743
740
EXPECT_EQ (chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED,
744
741
network_state_handler ()->GetTechnologyState (
@@ -765,9 +762,10 @@ TEST_F(TetherServiceTest, TestMultiDeviceSetupClientLosesVerifiedHost) {
765
762
chromeos::NetworkTypePattern::Tether ()));
766
763
VerifyTetherActiveStatus (true /* expected_active */ );
767
764
768
- fake_multidevice_setup_client_->SetHostStatusWithDevice (std::make_pair (
769
- chromeos::multidevice_setup::mojom::HostStatus::kNoEligibleHosts ,
770
- base::nullopt));
765
+ fake_multidevice_setup_client_->SetFeatureState (
766
+ chromeos::multidevice_setup::mojom::Feature::kInstantTethering ,
767
+ chromeos::multidevice_setup::mojom::FeatureState::
768
+ kUnavailableNoVerifiedHost );
771
769
772
770
EXPECT_EQ (
773
771
chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNAVAILABLE,
@@ -777,12 +775,79 @@ TEST_F(TetherServiceTest, TestMultiDeviceSetupClientLosesVerifiedHost) {
777
775
778
776
ShutdownTetherService ();
779
777
VerifyTetherFeatureStateRecorded (
780
- TetherService::TetherFeatureState::MULTIDEVICE_HOST_UNVERIFIED ,
778
+ TetherService::TetherFeatureState::NO_AVAILABLE_HOSTS ,
781
779
1 /* expected_count */ );
782
780
VerifyLastShutdownReason (chromeos::tether::TetherComponent::ShutdownReason::
783
781
MULTIDEVICE_HOST_UNVERIFIED);
784
782
}
785
783
784
+ TEST_F (TetherServiceTest, TestBetterTogetherSuiteInitiallyDisabled) {
785
+ base::test::ScopedFeatureList feature_list;
786
+ feature_list.InitWithFeatures (
787
+ {chromeos::features::kMultiDeviceApi ,
788
+ chromeos::features::
789
+ kEnableUnifiedMultiDeviceSetup } /* enabled_features */ ,
790
+ {} /* disabled_features */ );
791
+
792
+ initial_feature_state_ = chromeos::multidevice_setup::mojom::FeatureState::
793
+ kUnavailableSuiteDisabled ;
794
+
795
+ CreateTetherService ();
796
+
797
+ EXPECT_EQ (
798
+ chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNAVAILABLE,
799
+ network_state_handler ()->GetTechnologyState (
800
+ chromeos::NetworkTypePattern::Tether ()));
801
+ VerifyTetherActiveStatus (false /* expected_active */ );
802
+
803
+ fake_multidevice_setup_client_->SetFeatureState (
804
+ chromeos::multidevice_setup::mojom::Feature::kInstantTethering ,
805
+ chromeos::multidevice_setup::mojom::FeatureState::kEnabledByUser );
806
+
807
+ EXPECT_EQ (chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED,
808
+ network_state_handler ()->GetTechnologyState (
809
+ chromeos::NetworkTypePattern::Tether ()));
810
+ VerifyTetherActiveStatus (true /* expected_active */ );
811
+
812
+ ShutdownTetherService ();
813
+ VerifyLastShutdownReason (
814
+ chromeos::tether::TetherComponent::ShutdownReason::USER_LOGGED_OUT);
815
+ }
816
+
817
+ TEST_F (TetherServiceTest, TestBetterTogetherSuiteBecomesDisabled) {
818
+ base::test::ScopedFeatureList feature_list;
819
+ feature_list.InitWithFeatures (
820
+ {chromeos::features::kMultiDeviceApi ,
821
+ chromeos::features::
822
+ kEnableUnifiedMultiDeviceSetup } /* enabled_features */ ,
823
+ {} /* disabled_features */ );
824
+
825
+ CreateTetherService ();
826
+
827
+ EXPECT_EQ (chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED,
828
+ network_state_handler ()->GetTechnologyState (
829
+ chromeos::NetworkTypePattern::Tether ()));
830
+ VerifyTetherActiveStatus (true /* expected_active */ );
831
+
832
+ fake_multidevice_setup_client_->SetFeatureState (
833
+ chromeos::multidevice_setup::mojom::Feature::kInstantTethering ,
834
+ chromeos::multidevice_setup::mojom::FeatureState::
835
+ kUnavailableSuiteDisabled );
836
+
837
+ EXPECT_EQ (
838
+ chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNAVAILABLE,
839
+ network_state_handler ()->GetTechnologyState (
840
+ chromeos::NetworkTypePattern::Tether ()));
841
+ VerifyTetherActiveStatus (false /* expected_active */ );
842
+
843
+ ShutdownTetherService ();
844
+ VerifyTetherFeatureStateRecorded (
845
+ TetherService::TetherFeatureState::BETTER_TOGETHER_SUITE_DISABLED,
846
+ 1 /* expected_count */ );
847
+ VerifyLastShutdownReason (chromeos::tether::TetherComponent::ShutdownReason::
848
+ BETTER_TOGETHER_SUITE_DISABLED);
849
+ }
850
+
786
851
TEST_F (TetherServiceTest, TestBleAdvertisingNotSupported) {
787
852
mock_adapter_->set_is_ble_advertising_supported (false );
788
853
@@ -960,9 +1025,9 @@ TEST_F(
960
1025
ASSERT_TRUE (tether_service);
961
1026
962
1027
fake_multidevice_setup_client_impl_factory_->fake_multidevice_setup_client ()
963
- ->SetHostStatusWithDevice ( std::make_pair (
964
- chromeos::multidevice_setup::mojom::HostStatus:: kHostVerified ,
965
- test_devices_[ 0 ]) );
1028
+ ->SetFeatureState (
1029
+ chromeos::multidevice_setup::mojom::Feature:: kInstantTethering ,
1030
+ chromeos::multidevice_setup::mojom::FeatureState:: kEnabledByUser );
966
1031
967
1032
base::RunLoop ().RunUntilIdle ();
968
1033
tether_service->Shutdown ();
0 commit comments