fake_tether_controller.cc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/components/phonehub/fake_tether_controller.h"
  5. namespace ash {
  6. namespace phonehub {
  7. FakeTetherController::FakeTetherController()
  8. : status_(Status::kConnectionAvailable) {}
  9. FakeTetherController::~FakeTetherController() = default;
  10. void FakeTetherController::SetStatus(Status status) {
  11. if (status_ == status)
  12. return;
  13. status_ = status;
  14. NotifyStatusChanged();
  15. }
  16. TetherController::Status FakeTetherController::GetStatus() const {
  17. return status_;
  18. }
  19. void FakeTetherController::ScanForAvailableConnection() {
  20. num_scan_for_available_connection_calls_++;
  21. if (status_ == Status::kConnectionUnavailable)
  22. SetStatus(Status::kConnectionAvailable);
  23. }
  24. void FakeTetherController::AttemptConnection() {
  25. if (status_ == Status::kConnectionUnavailable ||
  26. status_ == Status::kConnectionAvailable) {
  27. SetStatus(Status::kConnecting);
  28. }
  29. }
  30. void FakeTetherController::Disconnect() {
  31. if (status_ == Status::kConnecting || status_ == Status::kConnected)
  32. SetStatus(Status::kConnecting);
  33. }
  34. } // namespace phonehub
  35. } // namespace ash