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

Side by Side Diff: content/browser/wake_lock/wake_lock_service_context_unittest.cc

Issue 2389743002: Content Modularization Project: Move Wake Lock to //device (Closed)
Patch Set: Eliminate frame reference Created 4 years, 2 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
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 "content/browser/wake_lock/wake_lock_service_context.h"
6
7 #include <memory>
8
9 #include "base/message_loop/message_loop.h"
10 #include "base/process/kill.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace content {
14
15 class WakeLockServiceContextTest : public testing::Test {
16 public:
17 WakeLockServiceContextTest()
18 : wake_lock_service_context_(
19 base::ThreadTaskRunnerHandle::Get(),
20 base::Bind(&WakeLockServiceContextTest::GetNativeView,
21 base::Unretained(this))) {}
22
23 protected:
24 void RequestWakeLock() { GetWakeLockServiceContext()->RequestWakeLock(); }
25
26 void CancelWakeLock() { GetWakeLockServiceContext()->CancelWakeLock(); }
27
28 WakeLockServiceContext* GetWakeLockServiceContext() {
29 return &wake_lock_service_context_;
30 }
31
32 bool HasWakeLock() {
33 return GetWakeLockServiceContext()->HasWakeLockForTests();
34 }
35
36 private:
37 gfx::NativeView GetNativeView() { return nullptr; }
38
39 base::MessageLoop message_loop_;
40 WakeLockServiceContext wake_lock_service_context_;
41 };
42
43 TEST_F(WakeLockServiceContextTest, NoLockInitially) {
44 EXPECT_FALSE(HasWakeLock());
45 }
46
47 TEST_F(WakeLockServiceContextTest, LockUnlock) {
48 ASSERT_TRUE(GetWakeLockServiceContext());
49
50 // Request wake lock.
51 RequestWakeLock();
52
53 // Should set the blocker.
54 EXPECT_TRUE(HasWakeLock());
55
56 // Remove wake lock request.
57 CancelWakeLock();
58
59 // Should remove the blocker.
60 EXPECT_FALSE(HasWakeLock());
61 }
62
63 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/wake_lock/wake_lock_service_context.cc ('k') | content/browser/wake_lock/wake_lock_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698