OLD | NEW |
---|---|
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 <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "chromeos/chromeos_switches.h" | 13 #include "chromeos/chromeos_switches.h" |
14 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
15 #include "chromeos/dbus/shill_device_client.h" | 15 #include "chromeos/dbus/shill_device_client.h" |
16 #include "chromeos/dbus/shill_manager_client.h" | |
17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "third_party/cros_system_api/dbus/service_constants.h" | 17 #include "third_party/cros_system_api/dbus/service_constants.h" |
19 | 18 |
20 namespace chromeos { | 19 namespace chromeos { |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
24 class TestObserver : public NetworkSmsHandler::Observer { | 23 class TestObserver : public NetworkSmsHandler::Observer { |
25 public: | 24 public: |
26 TestObserver() {} | 25 TestObserver() {} |
(...skipping 28 matching lines...) Expand all Loading... | |
55 virtual ~NetworkSmsHandlerTest() {} | 54 virtual ~NetworkSmsHandlerTest() {} |
56 | 55 |
57 virtual void SetUp() OVERRIDE { | 56 virtual void SetUp() OVERRIDE { |
58 // Append '--sms-test-messages' to the command line to tell | 57 // Append '--sms-test-messages' to the command line to tell |
59 // SMSClientStubImpl to generate a series of test SMS messages. | 58 // SMSClientStubImpl to generate a series of test SMS messages. |
60 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 59 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
61 command_line->AppendSwitch(chromeos::switches::kSmsTestMessages); | 60 command_line->AppendSwitch(chromeos::switches::kSmsTestMessages); |
62 | 61 |
63 // Initialize DBusThreadManager with a stub implementation. | 62 // Initialize DBusThreadManager with a stub implementation. |
64 DBusThreadManager::InitializeWithStub(); | 63 DBusThreadManager::InitializeWithStub(); |
65 ShillManagerClient::TestInterface* manager_test = | |
66 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); | |
67 ASSERT_TRUE(manager_test); | |
68 manager_test->AddDevice("stub_cellular_device2"); | |
69 ShillDeviceClient::TestInterface* device_test = | 64 ShillDeviceClient::TestInterface* device_test = |
70 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); | 65 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); |
71 ASSERT_TRUE(device_test); | 66 ASSERT_TRUE(device_test); |
72 device_test->AddDevice("stub_cellular_device2", shill::kTypeCellular, | 67 device_test->AddDevice("/org/freedesktop/ModemManager1/stub/0", |
73 "/org/freedesktop/ModemManager1/stub/0"); | 68 shill::kTypeCellular, |
69 "stub_cellular_device2"); | |
stevenjb
2014/05/28 23:06:10
Separate CL
| |
74 | 70 |
75 // This relies on the stub dbus implementations for ShillManagerClient, | 71 // This relies on the stub dbus implementations for ShillManagerClient, |
76 // ShillDeviceClient, GsmSMSClient, ModemMessagingClient and SMSClient. | 72 // ShillDeviceClient, GsmSMSClient, ModemMessagingClient and SMSClient. |
77 // Initialize a sms handler. The stub dbus clients will not send the | 73 // Initialize a sms handler. The stub dbus clients will not send the |
78 // first test message until RequestUpdate has been called. | 74 // first test message until RequestUpdate has been called. |
79 network_sms_handler_.reset(new NetworkSmsHandler()); | 75 network_sms_handler_.reset(new NetworkSmsHandler()); |
80 network_sms_handler_->Init(); | 76 network_sms_handler_->Init(); |
81 test_observer_.reset(new TestObserver()); | 77 test_observer_.reset(new TestObserver()); |
82 network_sms_handler_->AddObserver(test_observer_.get()); | 78 network_sms_handler_->AddObserver(test_observer_.get()); |
83 network_sms_handler_->RequestUpdate(true); | 79 network_sms_handler_->RequestUpdate(true); |
(...skipping 24 matching lines...) Expand all Loading... | |
108 | 104 |
109 // Test for messages delivered by signals. | 105 // Test for messages delivered by signals. |
110 test_observer_->ClearMessages(); | 106 test_observer_->ClearMessages(); |
111 network_sms_handler_->RequestUpdate(false); | 107 network_sms_handler_->RequestUpdate(false); |
112 message_loop_.RunUntilIdle(); | 108 message_loop_.RunUntilIdle(); |
113 EXPECT_GE(test_observer_->message_count(), 1); | 109 EXPECT_GE(test_observer_->message_count(), 1); |
114 EXPECT_NE(messages.find(kMessage1), messages.end()); | 110 EXPECT_NE(messages.find(kMessage1), messages.end()); |
115 } | 111 } |
116 | 112 |
117 } // namespace chromeos | 113 } // namespace chromeos |
OLD | NEW |