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

Unified Diff: device/wake_lock/wake_lock_service_impl_for_testing.cc

Issue 2883903002: Add service unittest for WakeLockServiceImpl. (Closed)
Patch Set: Rename Fake* to *ForTesting Created 3 years, 6 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
« no previous file with comments | « device/wake_lock/wake_lock_service_impl_for_testing.h ('k') | services/device/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/wake_lock/wake_lock_service_impl_for_testing.cc
diff --git a/device/wake_lock/wake_lock_service_impl_for_testing.cc b/device/wake_lock/wake_lock_service_impl_for_testing.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6dcd921d5e421303e3a4cf989486924bacf533fe
--- /dev/null
+++ b/device/wake_lock/wake_lock_service_impl_for_testing.cc
@@ -0,0 +1,57 @@
+// Copyright 2015 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 "device/wake_lock/wake_lock_service_impl_for_testing.h"
+
+#include <utility>
+
+namespace device {
+
+WakeLockServiceImplForTesting::WakeLockServiceImplForTesting(
+ mojom::WakeLockServiceRequest request,
+ mojom::WakeLockType type,
+ mojom::WakeLockReason reason,
+ const std::string& description,
+ int context_id,
+ WakeLockContextCallback native_view_getter,
+ scoped_refptr<base::SingleThreadTaskRunner> file_task_runner)
+ : WakeLockServiceImpl(std::move(request),
+ type,
+ reason,
+ description,
+ context_id,
+ native_view_getter,
+ file_task_runner),
+ has_wake_lock_(false) {}
+
+WakeLockServiceImplForTesting::~WakeLockServiceImplForTesting() {}
+
+void WakeLockServiceImplForTesting::HasWakeLockForTests(
+ HasWakeLockForTestsCallback callback) {
+ std::move(callback).Run(has_wake_lock_);
+}
+
+void WakeLockServiceImplForTesting::UpdateWakeLock() {
+ DCHECK(num_lock_requests_ >= 0);
+
+ if (num_lock_requests_) {
+ if (!has_wake_lock_)
+ CreateWakeLock();
+ } else {
+ if (has_wake_lock_)
+ RemoveWakeLock();
+ }
+}
+
+void WakeLockServiceImplForTesting::CreateWakeLock() {
+ DCHECK(!has_wake_lock_);
+ has_wake_lock_ = true;
+}
+
+void WakeLockServiceImplForTesting::RemoveWakeLock() {
+ DCHECK(has_wake_lock_);
+ has_wake_lock_ = false;
+}
+
+} // namespace device
« no previous file with comments | « device/wake_lock/wake_lock_service_impl_for_testing.h ('k') | services/device/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698