| 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" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 protected: | 63 protected: |
| 64 MessageLoopForUI message_loop_; | 64 MessageLoopForUI message_loop_; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 TEST_F(NetworkSmsHandlerTest, SmsHandlerDbusStub) { | 67 TEST_F(NetworkSmsHandlerTest, SmsHandlerDbusStub) { |
| 68 // Append '--sms-test-messages' to the command line to tell SMSClientStubImpl | 68 // Append '--sms-test-messages' to the command line to tell SMSClientStubImpl |
| 69 // to generate a series of test SMS messages. | 69 // to generate a series of test SMS messages. |
| 70 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 70 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 71 command_line->AppendSwitch(chromeos::switches::kSmsTestMessages); | 71 command_line->AppendSwitch(chromeos::switches::kSmsTestMessages); |
| 72 | 72 |
| 73 // This relies on the stub dbus implementations for FlimflamManagerClient, | 73 // This relies on the stub dbus implementations for ShillManagerClient, |
| 74 // FlimflamDeviceClient, GsmSMSClient, ModemMessagingClient and SMSClient. | 74 // ShillDeviceClient, GsmSMSClient, ModemMessagingClient and SMSClient. |
| 75 // Initialize a sms handler. The stub dbus clients will not send the | 75 // Initialize a sms handler. The stub dbus clients will not send the |
| 76 // first test message until RequestUpdate has been called. | 76 // first test message until RequestUpdate has been called. |
| 77 scoped_ptr<NetworkSmsHandler> sms_handler(new NetworkSmsHandler()); | 77 scoped_ptr<NetworkSmsHandler> sms_handler(new NetworkSmsHandler()); |
| 78 scoped_ptr<TestObserver> test_observer(new TestObserver()); | 78 scoped_ptr<TestObserver> test_observer(new TestObserver()); |
| 79 sms_handler->AddObserver(test_observer.get()); | 79 sms_handler->AddObserver(test_observer.get()); |
| 80 sms_handler->Init(); | 80 sms_handler->Init(); |
| 81 message_loop_.RunAllPending(); | 81 message_loop_.RunAllPending(); |
| 82 EXPECT_EQ(test_observer->message_count(), 0); | 82 EXPECT_EQ(test_observer->message_count(), 0); |
| 83 | 83 |
| 84 // Test that no messages have been received yet | 84 // Test that no messages have been received yet |
| 85 const std::set<std::string>& messages(test_observer->messages()); | 85 const std::set<std::string>& messages(test_observer->messages()); |
| 86 // Note: The following string corresponds to values in | 86 // Note: The following string corresponds to values in |
| 87 // ModemMessagingClientStubImpl and SmsClientStubImpl. | 87 // ModemMessagingClientStubImpl and SmsClientStubImpl. |
| 88 const char kMessage1[] = "SMSClientStubImpl: Test Message: /SMS/0"; | 88 const char kMessage1[] = "SMSClientStubImpl: Test Message: /SMS/0"; |
| 89 EXPECT_EQ(messages.find(kMessage1), messages.end()); | 89 EXPECT_EQ(messages.find(kMessage1), messages.end()); |
| 90 | 90 |
| 91 // Test for messages delivered by signals. | 91 // Test for messages delivered by signals. |
| 92 test_observer->ClearMessages(); | 92 test_observer->ClearMessages(); |
| 93 sms_handler->RequestUpdate(); | 93 sms_handler->RequestUpdate(); |
| 94 message_loop_.RunAllPending(); | 94 message_loop_.RunAllPending(); |
| 95 EXPECT_GE(test_observer->message_count(), 1); | 95 EXPECT_GE(test_observer->message_count(), 1); |
| 96 EXPECT_NE(messages.find(kMessage1), messages.end()); | 96 EXPECT_NE(messages.find(kMessage1), messages.end()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace chromeos | 99 } // namespace chromeos |
| OLD | NEW |