Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1123)

Unified Diff: chrome/browser/chromeos/tether/fake_tether_service.cc

Issue 2900903002: Create a FakeTetherService, which stubs out TetherService for development. (Closed)
Patch Set: Fix TetherService tests. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/tether/fake_tether_service.cc
diff --git a/chrome/browser/chromeos/tether/fake_tether_service.cc b/chrome/browser/chromeos/tether/fake_tether_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5fe6bc89084f19c338d61f8a607908c9667d2418
--- /dev/null
+++ b/chrome/browser/chromeos/tether/fake_tether_service.cc
@@ -0,0 +1,46 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/tether/fake_tether_service.h"
+
+constexpr char kTetherGuidPrefix[] = "tether-guid-";
+constexpr char kTetherNamePrefix[] = "tether";
+constexpr char kCarrier[] = "FakeCarrier";
+
+FakeTetherService::FakeTetherService(
+ Profile* profile,
+ chromeos::PowerManagerClient* power_manager_client,
+ chromeos::SessionManagerClient* session_manager_client,
+ cryptauth::CryptAuthService* cryptauth_service,
+ chromeos::NetworkStateHandler* network_state_handler)
+ : TetherService(profile,
+ power_manager_client,
+ session_manager_client,
+ cryptauth_service,
+ network_state_handler) {}
+
+void FakeTetherService::StartTetherIfEnabled() {
+ if (GetTetherTechnologyState() !=
+ chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED) {
+ return;
+ }
+
+ for (int i = 0; i < num_tether_networks_; ++i) {
+ network_state_handler()->AddTetherNetworkState(
+ kTetherGuidPrefix + std::to_string(i),
+ kTetherNamePrefix + std::to_string(i), kCarrier,
+ 100 /* battery_percentage */, 100 /* signal_strength */,
+ false /* has_connected_to_host */);
+ }
+}
+
+void FakeTetherService::StopTether() {
+ for (int i = 0; i < num_tether_networks_; ++i) {
+ network_state_handler()->RemoveTetherNetworkState(kTetherGuidPrefix + i);
+ }
+}
+
+bool FakeTetherService::HasSyncedTetherHosts() const {
+ return true;
+}
« no previous file with comments | « chrome/browser/chromeos/tether/fake_tether_service.h ('k') | chrome/browser/chromeos/tether/tether_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698