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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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
5 #include "device/wake_lock/wake_lock_service_impl_for_testing.h"
6
7 #include <utility>
8
9 namespace device {
10
11 WakeLockServiceImplForTesting::WakeLockServiceImplForTesting(
12 mojom::WakeLockServiceRequest request,
13 mojom::WakeLockType type,
14 mojom::WakeLockReason reason,
15 const std::string& description,
16 int context_id,
17 WakeLockContextCallback native_view_getter,
18 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner)
19 : WakeLockServiceImpl(std::move(request),
20 type,
21 reason,
22 description,
23 context_id,
24 native_view_getter,
25 file_task_runner),
26 has_wake_lock_(false) {}
27
28 WakeLockServiceImplForTesting::~WakeLockServiceImplForTesting() {}
29
30 void WakeLockServiceImplForTesting::HasWakeLockForTests(
31 HasWakeLockForTestsCallback callback) {
32 std::move(callback).Run(has_wake_lock_);
33 }
34
35 void WakeLockServiceImplForTesting::UpdateWakeLock() {
36 DCHECK(num_lock_requests_ >= 0);
37
38 if (num_lock_requests_) {
39 if (!has_wake_lock_)
40 CreateWakeLock();
41 } else {
42 if (has_wake_lock_)
43 RemoveWakeLock();
44 }
45 }
46
47 void WakeLockServiceImplForTesting::CreateWakeLock() {
48 DCHECK(!has_wake_lock_);
49 has_wake_lock_ = true;
50 }
51
52 void WakeLockServiceImplForTesting::RemoveWakeLock() {
53 DCHECK(has_wake_lock_);
54 has_wake_lock_ = false;
55 }
56
57 } // namespace device
OLDNEW
« 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