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

Side by Side Diff: content/child/power_monitor_broadcast_source_unittest.cc

Issue 2082343002: Remove calls to deprecated MessageLoop methods in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Created 4 years, 5 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/macros.h" 5 #include "base/macros.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/run_loop.h"
7 #include "base/test/power_monitor_test_base.h" 8 #include "base/test/power_monitor_test_base.h"
8 #include "content/child/power_monitor_broadcast_source.h" 9 #include "content/child/power_monitor_broadcast_source.h"
9 #include "content/common/power_monitor_messages.h" 10 #include "content/common/power_monitor_messages.h"
10 #include "ipc/message_filter.h" 11 #include "ipc/message_filter.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace content { 14 namespace content {
14 15
15 class PowerMonitorBroadcastSourceTest : public testing::Test { 16 class PowerMonitorBroadcastSourceTest : public testing::Test {
16 protected: 17 protected:
(...skipping 20 matching lines...) Expand all
37 IPC::MessageFilter* message_filter = source()->GetMessageFilter(); 38 IPC::MessageFilter* message_filter = source()->GetMessageFilter();
38 39
39 base::PowerMonitorTestObserver observer; 40 base::PowerMonitorTestObserver observer;
40 monitor()->AddObserver(&observer); 41 monitor()->AddObserver(&observer);
41 42
42 PowerMonitorMsg_Suspend suspend_msg; 43 PowerMonitorMsg_Suspend suspend_msg;
43 PowerMonitorMsg_Resume resume_msg; 44 PowerMonitorMsg_Resume resume_msg;
44 45
45 // Sending resume when not suspended should have no effect. 46 // Sending resume when not suspended should have no effect.
46 message_filter->OnMessageReceived(resume_msg); 47 message_filter->OnMessageReceived(resume_msg);
47 message_loop_.RunUntilIdle(); 48 base::RunLoop().RunUntilIdle();
48 EXPECT_EQ(observer.resumes(), 0); 49 EXPECT_EQ(observer.resumes(), 0);
49 50
50 // Pretend we suspended. 51 // Pretend we suspended.
51 message_filter->OnMessageReceived(suspend_msg); 52 message_filter->OnMessageReceived(suspend_msg);
52 message_loop_.RunUntilIdle(); 53 base::RunLoop().RunUntilIdle();
53 EXPECT_EQ(observer.suspends(), 1); 54 EXPECT_EQ(observer.suspends(), 1);
54 55
55 // Send a second suspend notification. This should be suppressed. 56 // Send a second suspend notification. This should be suppressed.
56 message_filter->OnMessageReceived(suspend_msg); 57 message_filter->OnMessageReceived(suspend_msg);
57 message_loop_.RunUntilIdle(); 58 base::RunLoop().RunUntilIdle();
58 EXPECT_EQ(observer.suspends(), 1); 59 EXPECT_EQ(observer.suspends(), 1);
59 60
60 // Pretend we were awakened. 61 // Pretend we were awakened.
61 message_filter->OnMessageReceived(resume_msg); 62 message_filter->OnMessageReceived(resume_msg);
62 message_loop_.RunUntilIdle(); 63 base::RunLoop().RunUntilIdle();
63 EXPECT_EQ(observer.resumes(), 1); 64 EXPECT_EQ(observer.resumes(), 1);
64 65
65 // Send a duplicate resume notification. This should be suppressed. 66 // Send a duplicate resume notification. This should be suppressed.
66 message_filter->OnMessageReceived(resume_msg); 67 message_filter->OnMessageReceived(resume_msg);
67 message_loop_.RunUntilIdle(); 68 base::RunLoop().RunUntilIdle();
68 EXPECT_EQ(observer.resumes(), 1); 69 EXPECT_EQ(observer.resumes(), 1);
69 70
70 PowerMonitorMsg_PowerStateChange on_battery_msg(true); 71 PowerMonitorMsg_PowerStateChange on_battery_msg(true);
71 PowerMonitorMsg_PowerStateChange off_battery_msg(false); 72 PowerMonitorMsg_PowerStateChange off_battery_msg(false);
72 73
73 // Pretend the device has gone on battery power 74 // Pretend the device has gone on battery power
74 message_filter->OnMessageReceived(on_battery_msg); 75 message_filter->OnMessageReceived(on_battery_msg);
75 message_loop_.RunUntilIdle(); 76 base::RunLoop().RunUntilIdle();
76 EXPECT_EQ(observer.power_state_changes(), 1); 77 EXPECT_EQ(observer.power_state_changes(), 1);
77 EXPECT_EQ(observer.last_power_state(), true); 78 EXPECT_EQ(observer.last_power_state(), true);
78 79
79 // Repeated indications the device is on battery power should be suppressed. 80 // Repeated indications the device is on battery power should be suppressed.
80 message_filter->OnMessageReceived(on_battery_msg); 81 message_filter->OnMessageReceived(on_battery_msg);
81 message_loop_.RunUntilIdle(); 82 base::RunLoop().RunUntilIdle();
82 EXPECT_EQ(observer.power_state_changes(), 1); 83 EXPECT_EQ(observer.power_state_changes(), 1);
83 84
84 // Pretend the device has gone off battery power 85 // Pretend the device has gone off battery power
85 message_filter->OnMessageReceived(off_battery_msg); 86 message_filter->OnMessageReceived(off_battery_msg);
86 message_loop_.RunUntilIdle(); 87 base::RunLoop().RunUntilIdle();
87 EXPECT_EQ(observer.power_state_changes(), 2); 88 EXPECT_EQ(observer.power_state_changes(), 2);
88 EXPECT_EQ(observer.last_power_state(), false); 89 EXPECT_EQ(observer.last_power_state(), false);
89 90
90 // Repeated indications the device is off battery power should be suppressed. 91 // Repeated indications the device is off battery power should be suppressed.
91 message_filter->OnMessageReceived(off_battery_msg); 92 message_filter->OnMessageReceived(off_battery_msg);
92 message_loop_.RunUntilIdle(); 93 base::RunLoop().RunUntilIdle();
93 EXPECT_EQ(observer.power_state_changes(), 2); 94 EXPECT_EQ(observer.power_state_changes(), 2);
94 } 95 }
95 96
96 } // namespace base 97 } // namespace base
OLDNEW
« no previous file with comments | « content/browser/webui/url_data_manager_backend.cc ('k') | content/child/shared_memory_data_consumer_handle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698