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

Side by Side Diff: chromeos/network/network_sms_handler_unittest.cc

Issue 2314853004: Remove calls to deprecated MessageLoop methods in chromeos. (Closed)
Patch Set: Created 4 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chromeos/network/network_sms_handler.h" 5 #include "chromeos/network/network_sms_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h"
13 #include "chromeos/chromeos_switches.h" 14 #include "chromeos/chromeos_switches.h"
14 #include "chromeos/dbus/dbus_thread_manager.h" 15 #include "chromeos/dbus/dbus_thread_manager.h"
15 #include "chromeos/dbus/shill_device_client.h" 16 #include "chromeos/dbus/shill_device_client.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
18 19
19 namespace chromeos { 20 namespace chromeos {
20 21
21 namespace { 22 namespace {
22 23
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 71
71 // This relies on the stub dbus implementations for ShillManagerClient, 72 // This relies on the stub dbus implementations for ShillManagerClient,
72 // ShillDeviceClient, GsmSMSClient, ModemMessagingClient and SMSClient. 73 // ShillDeviceClient, GsmSMSClient, ModemMessagingClient and SMSClient.
73 // Initialize a sms handler. The stub dbus clients will not send the 74 // Initialize a sms handler. The stub dbus clients will not send the
74 // first test message until RequestUpdate has been called. 75 // first test message until RequestUpdate has been called.
75 network_sms_handler_.reset(new NetworkSmsHandler()); 76 network_sms_handler_.reset(new NetworkSmsHandler());
76 network_sms_handler_->Init(); 77 network_sms_handler_->Init();
77 test_observer_.reset(new TestObserver()); 78 test_observer_.reset(new TestObserver());
78 network_sms_handler_->AddObserver(test_observer_.get()); 79 network_sms_handler_->AddObserver(test_observer_.get());
79 network_sms_handler_->RequestUpdate(true); 80 network_sms_handler_->RequestUpdate(true);
80 message_loop_.RunUntilIdle(); 81 base::RunLoop().RunUntilIdle();
81 } 82 }
82 83
83 void TearDown() override { 84 void TearDown() override {
84 network_sms_handler_->RemoveObserver(test_observer_.get()); 85 network_sms_handler_->RemoveObserver(test_observer_.get());
85 network_sms_handler_.reset(); 86 network_sms_handler_.reset();
86 DBusThreadManager::Shutdown(); 87 DBusThreadManager::Shutdown();
87 } 88 }
88 89
89 protected: 90 protected:
90 base::MessageLoopForUI message_loop_; 91 base::MessageLoopForUI message_loop_;
armansito 2016/09/06 22:04:32 ditto
91 std::unique_ptr<NetworkSmsHandler> network_sms_handler_; 92 std::unique_ptr<NetworkSmsHandler> network_sms_handler_;
92 std::unique_ptr<TestObserver> test_observer_; 93 std::unique_ptr<TestObserver> test_observer_;
93 }; 94 };
94 95
95 TEST_F(NetworkSmsHandlerTest, SmsHandlerDbusStub) { 96 TEST_F(NetworkSmsHandlerTest, SmsHandlerDbusStub) {
96 EXPECT_EQ(test_observer_->message_count(), 0); 97 EXPECT_EQ(test_observer_->message_count(), 0);
97 98
98 // Test that no messages have been received yet 99 // Test that no messages have been received yet
99 const std::set<std::string>& messages(test_observer_->messages()); 100 const std::set<std::string>& messages(test_observer_->messages());
100 // Note: The following string corresponds to values in 101 // Note: The following string corresponds to values in
101 // ModemMessagingClientStubImpl and SmsClientStubImpl. 102 // ModemMessagingClientStubImpl and SmsClientStubImpl.
102 // TODO(stevenjb): Use a TestInterface to set this up to remove dependency. 103 // TODO(stevenjb): Use a TestInterface to set this up to remove dependency.
103 const char kMessage1[] = "FakeSMSClient: Test Message: /SMS/0"; 104 const char kMessage1[] = "FakeSMSClient: Test Message: /SMS/0";
104 EXPECT_EQ(messages.find(kMessage1), messages.end()); 105 EXPECT_EQ(messages.find(kMessage1), messages.end());
105 106
106 // Test for messages delivered by signals. 107 // Test for messages delivered by signals.
107 test_observer_->ClearMessages(); 108 test_observer_->ClearMessages();
108 network_sms_handler_->RequestUpdate(false); 109 network_sms_handler_->RequestUpdate(false);
109 message_loop_.RunUntilIdle(); 110 base::RunLoop().RunUntilIdle();
110 EXPECT_GE(test_observer_->message_count(), 1); 111 EXPECT_GE(test_observer_->message_count(), 1);
111 EXPECT_NE(messages.find(kMessage1), messages.end()); 112 EXPECT_NE(messages.find(kMessage1), messages.end());
112 } 113 }
113 114
114 } // namespace chromeos 115 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698