File: hotspot_controller_concurrency_api_unittest.cc

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (490 lines) | stat: -rw-r--r-- 19,790 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/values.h"
#include "chromeos/ash/components/dbus/shill/shill_clients.h"
#include "chromeos/ash/components/dbus/shill/shill_manager_client.h"
#include "chromeos/ash/components/network/enterprise_managed_metadata_store.h"
#include "chromeos/ash/components/network/hotspot_allowed_flag_handler.h"
#include "chromeos/ash/components/network/hotspot_capabilities_provider.h"
#include "chromeos/ash/components/network/hotspot_controller.h"
#include "chromeos/ash/components/network/hotspot_state_handler.h"
#include "chromeos/ash/components/network/metrics/hotspot_feature_usage_metrics.h"
#include "chromeos/ash/components/network/metrics/hotspot_metrics_helper.h"
#include "chromeos/ash/components/network/network_state_handler.h"
#include "chromeos/ash/components/network/network_state_test_helper.h"
#include "chromeos/ash/services/hotspot_config/public/mojom/cros_hotspot_config.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/cros_system_api/dbus/shill/dbus-constants.h"

namespace ash {

namespace {

const char kCellularServicePath[] = "/service/cellular0";
const char kCellularServiceGuid[] = "cellular_guid0";
const char kCellularServiceName[] = "cellular_name0";
const char kHotspotFeatureUsage[] = "ChromeOS.FeatureUsage.Hotspot";

class TestObserver : public HotspotController::Observer {
 public:
  TestObserver() = default;
  ~TestObserver() override = default;

  // HotspotStateHandler::Observer:
  void OnHotspotTurnedOn() override { hotspot_turned_on_count_++; }
  void OnHotspotTurnedOff(
      hotspot_config::mojom::DisableReason disable_reason) override {
    last_disable_reason_ = disable_reason;
    hotspot_turned_off_count_++;
  }

  size_t hotspot_turned_on_count() { return hotspot_turned_on_count_; }

  size_t hotspot_turned_off_count() { return hotspot_turned_off_count_; }

  std::optional<hotspot_config::mojom::DisableReason> last_disable_reason() {
    return last_disable_reason_;
  }

 private:
  size_t hotspot_turned_on_count_ = 0u;
  size_t hotspot_turned_off_count_ = 0u;
  std::optional<hotspot_config::mojom::DisableReason> last_disable_reason_ =
      std::nullopt;
};

}  // namespace

class HotspotControllerConcurrencyApiTest : public ::testing::Test {
 public:
  // This struct is used to simplify checking the metrics associated with the
  // tests below.
  struct ExpectedHistogramState {
    size_t success_initial_count = 0u;
    size_t success_retry_count = 0u;
    size_t inhibit_failed_initial_count = 0u;
    size_t inhibit_failed_retry_count = 0u;
    size_t hermes_install_failed_initial_count = 0u;
    size_t hermes_install_failed_retry_count = 0u;
    size_t smds_scan_profile_total_count = 0u;
    size_t smds_scan_profile_sum = 0u;
    size_t no_available_profiles_via_smdp_count = 0u;
    size_t no_available_profiles_via_smds_count = 0u;
    size_t install_method_via_smdp_count = 0u;
    size_t install_method_via_smds_count = 0u;
    size_t scan_duration_other_success_count = 0u;
    size_t scan_duration_other_failure_count = 0u;
    size_t scan_duration_android_success_count = 0u;
    size_t scan_duration_android_failure_count = 0u;
    size_t scan_duration_gsma_success_count = 0u;
    size_t scan_duration_gsma_failure_count = 0u;
  };

  HotspotControllerConcurrencyApiTest() {
    feature_list_.InitAndEnableFeature(features::kWifiConcurrency);
  }
  ~HotspotControllerConcurrencyApiTest() override = default;

  void SetUp() override {
    enterprise_managed_metadata_store_ =
        std::make_unique<EnterpriseManagedMetadataStore>();
    hotspot_capabilities_provider_ =
        std::make_unique<HotspotCapabilitiesProvider>();
    hotspot_allowed_flag_handler_ =
        std::make_unique<HotspotAllowedFlagHandler>();
    hotspot_capabilities_provider_->Init(
        network_state_test_helper_.network_state_handler(),
        hotspot_allowed_flag_handler_.get());
    hotspot_feature_usage_metrics_ =
        std::make_unique<HotspotFeatureUsageMetrics>();
    hotspot_feature_usage_metrics_->Init(
        enterprise_managed_metadata_store_.get(),
        hotspot_capabilities_provider_.get());
    hotspot_state_handler_ = std::make_unique<HotspotStateHandler>();
    hotspot_state_handler_->Init();
    hotspot_controller_ = std::make_unique<HotspotController>();
    hotspot_controller_->Init(
        hotspot_capabilities_provider_.get(),
        hotspot_feature_usage_metrics_.get(), hotspot_state_handler_.get(),
        network_state_test_helper_.technology_state_controller());
    hotspot_controller_->AddObserver(&observer_);
    SetReadinessCheckResultReady();
  }

  void TearDown() override {
    hotspot_controller_->RemoveObserver(&observer_);
    hotspot_controller_.reset();
    hotspot_feature_usage_metrics_.reset();
    hotspot_capabilities_provider_.reset();
    hotspot_allowed_flag_handler_.reset();
    hotspot_state_handler_.reset();
    enterprise_managed_metadata_store_.reset();
  }

  void SetHotspotAllowed() {
    hotspot_capabilities_provider_->SetHotspotAllowStatus(
        hotspot_config::mojom::HotspotAllowStatus::kAllowed);
  }

  void SetHotspotStateInShill(const std::string& state) {
    auto status_dict =
        base::Value::Dict().Set(shill::kTetheringStatusStateProperty, state);
    network_state_test_helper_.manager_test()->SetManagerProperty(
        shill::kTetheringStatusProperty, base::Value(std::move(status_dict)));
    base::RunLoop().RunUntilIdle();
  }

  void SetReadinessCheckResultReady() {
    network_state_test_helper_.manager_test()
        ->SetSimulateCheckTetheringReadinessResult(
            FakeShillSimulatedResult::kSuccess,
            shill::kTetheringReadinessReady);
    base::RunLoop().RunUntilIdle();
  }

  void AddActiveCellularService() {
    ShillServiceClient::TestInterface* service_test =
        network_state_test_helper_.service_test();
    service_test->AddService(kCellularServicePath, kCellularServiceGuid,
                             kCellularServiceName, shill::kTypeCellular,
                             shill::kStateOnline, /*visible=*/true);
  }

  hotspot_config::mojom::HotspotControlResult EnableHotspot() {
    base::RunLoop run_loop;
    hotspot_config::mojom::HotspotControlResult return_result;
    hotspot_controller_->EnableHotspot(base::BindLambdaForTesting(
        [&](hotspot_config::mojom::HotspotControlResult result) {
          return_result = result;
          run_loop.Quit();
        }));
    run_loop.Run();
    FlushMojoCalls();
    return return_result;
  }

  hotspot_config::mojom::HotspotControlResult DisableHotspot() {
    base::RunLoop run_loop;
    hotspot_config::mojom::HotspotControlResult return_result;
    hotspot_controller_->DisableHotspot(
        base::BindLambdaForTesting(
            [&](hotspot_config::mojom::HotspotControlResult result) {
              return_result = result;
              run_loop.Quit();
            }),
        hotspot_config::mojom::DisableReason::kUserInitiated);
    run_loop.Run();
    FlushMojoCalls();
    return return_result;
  }

  bool PrepareEnableWifi() {
    base::RunLoop run_loop;
    bool prepare_success;
    hotspot_controller_->PrepareEnableWifi(
        base::BindLambdaForTesting([&](bool result) {
          prepare_success = result;
          run_loop.Quit();
        }));
    run_loop.Run();
    FlushMojoCalls();
    return prepare_success;
  }

  void SetPolicyAllowHotspot(bool allow_hotspot) {
    base::RunLoop run_loop;
    hotspot_controller_->SetPolicyAllowHotspot(allow_hotspot);
    run_loop.RunUntilIdle();
  }

  void EnableAndAbortHotspot() {
    base::RunLoop run_loop;
    hotspot_config::mojom::HotspotControlResult enable_result =
        hotspot_config::mojom::HotspotControlResult::kUnknownFailure;
    hotspot_config::mojom::HotspotControlResult disable_result =
        hotspot_config::mojom::HotspotControlResult::kUnknownFailure;
    hotspot_controller_->EnableHotspot(base::BindLambdaForTesting(
        [&](hotspot_config::mojom::HotspotControlResult result) {
          enable_result = result;
          run_loop.Quit();
        }));
    hotspot_controller_->DisableHotspot(
        base::BindLambdaForTesting(
            [&](hotspot_config::mojom::HotspotControlResult result) {
              disable_result = result;
              run_loop.Quit();
            }),
        hotspot_config::mojom::DisableReason::kUserInitiated);
    run_loop.Run();
    FlushMojoCalls();

    EXPECT_EQ(hotspot_config::mojom::HotspotControlResult::kAborted,
              enable_result);
    EXPECT_EQ(hotspot_config::mojom::HotspotControlResult::kAlreadyFulfilled,
              disable_result);
  }

  void FlushMojoCalls() { base::RunLoop().RunUntilIdle(); }

 protected:
  base::test::TaskEnvironment task_environment_{
      base::test::TaskEnvironment::TimeSource::MOCK_TIME};
  base::HistogramTester histogram_tester_;
  base::test::ScopedFeatureList feature_list_;
  std::unique_ptr<EnterpriseManagedMetadataStore>
      enterprise_managed_metadata_store_;
  std::unique_ptr<HotspotController> hotspot_controller_;
  std::unique_ptr<HotspotCapabilitiesProvider> hotspot_capabilities_provider_;
  std::unique_ptr<HotspotAllowedFlagHandler> hotspot_allowed_flag_handler_;
  std::unique_ptr<HotspotFeatureUsageMetrics> hotspot_feature_usage_metrics_;
  std::unique_ptr<HotspotStateHandler> hotspot_state_handler_;
  NetworkStateTestHelper network_state_test_helper_{
      /*use_default_devices_and_services=*/false};
  TestObserver observer_;
};

TEST_F(HotspotControllerConcurrencyApiTest, EnableTetheringSuccess) {
  SetHotspotAllowed();
  AddActiveCellularService();
  network_state_test_helper_.manager_test()->SetSimulateTetheringEnableResult(
      FakeShillSimulatedResult::kSuccess, shill::kTetheringEnableResultSuccess);
  base::RunLoop().RunUntilIdle();

  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotCheckReadinessResultHistogram, 1);
  histogram_tester_.ExpectBucketCount(
      HotspotMetricsHelper::kHotspotCheckReadinessResultHistogram,
      HotspotMetricsHelper::HotspotMetricsCheckReadinessResult::kReady, 1);

  EXPECT_EQ(hotspot_config::mojom::HotspotControlResult::kSuccess,
            EnableHotspot());
  // Verifies that Wifi technology will be turned off.
  EXPECT_EQ(
      NetworkStateHandler::TECHNOLOGY_AVAILABLE,
      network_state_test_helper_.network_state_handler()->GetTechnologyState(
          NetworkTypePattern::WiFi()));

  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotEnableLatency, 1);
  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotCheckReadinessResultHistogram, 2);
  histogram_tester_.ExpectBucketCount(
      HotspotMetricsHelper::kHotspotCheckReadinessResultHistogram,
      HotspotMetricsHelper::HotspotMetricsCheckReadinessResult::kReady, 2);
  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotEnableResultHistogram, 1);
  histogram_tester_.ExpectBucketCount(
      HotspotMetricsHelper::kHotspotEnableResultHistogram,
      HotspotMetricsHelper::HotspotMetricsSetEnabledResult::kSuccess, 1);
  histogram_tester_.ExpectBucketCount(
      kHotspotFeatureUsage,
      static_cast<int>(
          feature_usage::FeatureUsageMetrics::Event::kUsedWithSuccess),
      1);
}

TEST_F(HotspotControllerConcurrencyApiTest, AbortEnableTethering) {
  SetHotspotAllowed();
  AddActiveCellularService();
  network_state_test_helper_.manager_test()->SetSimulateTetheringEnableResult(
      FakeShillSimulatedResult::kSuccess, shill::kTetheringEnableResultSuccess);
  base::RunLoop().RunUntilIdle();

  EnableAndAbortHotspot();

  histogram_tester_.ExpectBucketCount(
      HotspotMetricsHelper::kHotspotEnableResultHistogram,
      HotspotMetricsHelper::HotspotMetricsSetEnabledResult::kAborted, 1);
}

TEST_F(HotspotControllerConcurrencyApiTest,
       ShillOperationFailureWhileAborting) {
  SetHotspotAllowed();
  AddActiveCellularService();
  base::RunLoop().RunUntilIdle();

  network_state_test_helper_.manager_test()->SetSimulateTetheringEnableResult(
      FakeShillSimulatedResult::kSuccess,
      shill::kTetheringEnableResultNetworkSetupFailure);
  base::RunLoop().RunUntilIdle();

  EnableAndAbortHotspot();

  histogram_tester_.ExpectBucketCount(
      HotspotMetricsHelper::kHotspotEnableResultHistogram,
      HotspotMetricsHelper::HotspotMetricsSetEnabledResult::kAborted, 1);
}

TEST_F(HotspotControllerConcurrencyApiTest,
       EnableTetheringReadinessCheckFailure) {
  // Setup the hotspot capabilities so that the initial hotspot allowance
  // status is allowed.
  SetHotspotAllowed();
  AddActiveCellularService();
  base::RunLoop().RunUntilIdle();

  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotCheckReadinessResultHistogram, 1);
  histogram_tester_.ExpectBucketCount(
      HotspotMetricsHelper::kHotspotCheckReadinessResultHistogram,
      HotspotMetricsHelper::HotspotMetricsCheckReadinessResult::kReady, 1);

  // Simulate check tethering readiness operation fail.
  network_state_test_helper_.manager_test()
      ->SetSimulateCheckTetheringReadinessResult(
          FakeShillSimulatedResult::kFailure,
          /*readiness_status=*/std::string());
  base::RunLoop().RunUntilIdle();

  EXPECT_EQ(hotspot_config::mojom::HotspotControlResult::kReadinessCheckFailed,
            EnableHotspot());
  EXPECT_EQ(
      hotspot_config::mojom::HotspotAllowStatus::kDisallowedReadinessCheckFail,
      hotspot_capabilities_provider_->GetHotspotCapabilities().allow_status);

  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotEnableLatency, 1);
  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotCheckReadinessResultHistogram, 2);
  histogram_tester_.ExpectBucketCount(
      HotspotMetricsHelper::kHotspotCheckReadinessResultHistogram,
      HotspotMetricsHelper::HotspotMetricsCheckReadinessResult::
          kShillOperationFailed,
      1);
  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotEnableResultHistogram, 1);
  histogram_tester_.ExpectBucketCount(
      HotspotMetricsHelper::kHotspotEnableResultHistogram,
      HotspotMetricsHelper::HotspotMetricsSetEnabledResult::
          kReadinessCheckFailure,
      1);
}

TEST_F(HotspotControllerConcurrencyApiTest,
       EnableTetheringNetworkSetupFailure) {
  // Setup the hotspot capabilities so that the initial hotspot allowance
  // status is allowed.
  SetHotspotAllowed();
  AddActiveCellularService();
  base::RunLoop().RunUntilIdle();

  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotCheckReadinessResultHistogram, 1);
  histogram_tester_.ExpectBucketCount(
      HotspotMetricsHelper::kHotspotCheckReadinessResultHistogram,
      HotspotMetricsHelper::HotspotMetricsCheckReadinessResult::kReady, 1);

  // Simulate enable tethering operation fail with
  // kTetheringEnableResultNetworkSetupFailure error.
  network_state_test_helper_.manager_test()->SetSimulateTetheringEnableResult(
      FakeShillSimulatedResult::kSuccess,
      shill::kTetheringEnableResultNetworkSetupFailure);
  base::RunLoop().RunUntilIdle();

  EXPECT_EQ(hotspot_config::mojom::HotspotControlResult::kNetworkSetupFailure,
            EnableHotspot());
  // Verifies that Wifi technology will still be on if enable hotspot failed.
  EXPECT_EQ(
      NetworkStateHandler::TECHNOLOGY_ENABLED,
      network_state_test_helper_.network_state_handler()->GetTechnologyState(
          NetworkTypePattern::WiFi()));

  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotEnableLatency, 1);
  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotCheckReadinessResultHistogram, 2);
  histogram_tester_.ExpectBucketCount(
      HotspotMetricsHelper::kHotspotCheckReadinessResultHistogram,
      HotspotMetricsHelper::HotspotMetricsCheckReadinessResult::kReady, 2);
  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotEnableResultHistogram, 1);
  histogram_tester_.ExpectBucketCount(
      HotspotMetricsHelper::kHotspotEnableResultHistogram,
      HotspotMetricsHelper::HotspotMetricsSetEnabledResult::
          kNetworkSetupFailure,
      1);
  histogram_tester_.ExpectBucketCount(
      kHotspotFeatureUsage,
      static_cast<int>(
          feature_usage::FeatureUsageMetrics::Event::kUsedWithFailure),
      1);
}

TEST_F(HotspotControllerConcurrencyApiTest, DisableTetheringSuccess) {
  EXPECT_EQ(hotspot_config::mojom::HotspotControlResult::kAlreadyFulfilled,
            DisableHotspot());
  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotDisableResultHistogram, 1);
  histogram_tester_.ExpectBucketCount(
      HotspotMetricsHelper::kHotspotDisableResultHistogram,
      HotspotMetricsHelper::HotspotMetricsSetEnabledResult::kAlreadyFulfilled,
      1);

  SetHotspotStateInShill(shill::kTetheringStateActive);
  network_state_test_helper_.manager_test()->SetSimulateTetheringEnableResult(
      FakeShillSimulatedResult::kSuccess, shill::kTetheringEnableResultSuccess);
  EXPECT_EQ(hotspot_config::mojom::HotspotControlResult::kSuccess,
            DisableHotspot());
  histogram_tester_.ExpectTotalCount(
      HotspotMetricsHelper::kHotspotDisableResultHistogram, 2);
  histogram_tester_.ExpectBucketCount(
      HotspotMetricsHelper::kHotspotDisableResultHistogram,
      HotspotMetricsHelper::HotspotMetricsSetEnabledResult::kSuccess, 1);
}

TEST_F(HotspotControllerConcurrencyApiTest, SetPolicyAllowHotspot) {
  network_state_test_helper_.manager_test()->SetSimulateTetheringEnableResult(
      FakeShillSimulatedResult::kSuccess, shill::kTetheringEnableResultSuccess);
  SetHotspotStateInShill(shill::kTetheringStateActive);
  SetHotspotAllowed();
  SetPolicyAllowHotspot(/*allow_hotspot=*/false);
  EXPECT_EQ(1u, observer_.hotspot_turned_off_count());
  EXPECT_EQ(hotspot_config::mojom::DisableReason::kProhibitedByPolicy,
            observer_.last_disable_reason());
  EXPECT_EQ(
      hotspot_config::mojom::HotspotAllowStatus::kDisallowedByPolicy,
      hotspot_capabilities_provider_->GetHotspotCapabilities().allow_status);

  SetPolicyAllowHotspot(/*allow_hotspot=*/true);
  EXPECT_EQ(
      hotspot_config::mojom::HotspotAllowStatus::kAllowed,
      hotspot_capabilities_provider_->GetHotspotCapabilities().allow_status);
}

TEST_F(HotspotControllerConcurrencyApiTest, RestoreWiFiStatus) {
  SetHotspotAllowed();
  AddActiveCellularService();
  // Verify Wifi is on before turning on hotspot.
  EXPECT_EQ(
      NetworkStateHandler::TECHNOLOGY_ENABLED,
      network_state_test_helper_.network_state_handler()->GetTechnologyState(
          NetworkTypePattern::WiFi()));

  network_state_test_helper_.manager_test()->SetSimulateTetheringEnableResult(
      FakeShillSimulatedResult::kSuccess, shill::kTetheringEnableResultSuccess);
  base::RunLoop().RunUntilIdle();
  EXPECT_EQ(hotspot_config::mojom::HotspotControlResult::kSuccess,
            EnableHotspot());

  // Verifies that Wifi will be turned off.
  EXPECT_EQ(
      NetworkStateHandler::TECHNOLOGY_AVAILABLE,
      network_state_test_helper_.network_state_handler()->GetTechnologyState(
          NetworkTypePattern::WiFi()));

  SetHotspotStateInShill(shill::kTetheringStateIdle);
  base::RunLoop().RunUntilIdle();
  // Verifies that Wifi will be turned back on.
  EXPECT_EQ(
      NetworkStateHandler::TECHNOLOGY_ENABLED,
      network_state_test_helper_.network_state_handler()->GetTechnologyState(
          NetworkTypePattern::WiFi()));
}

}  // namespace ash