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

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

Issue 10828267: Add kSmsTestMessages switch to sms handler unititest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop.h" 12 #include "base/message_loop.h"
12 #include "chromeos/dbus/dbus_thread_manager.h" 13 #include "chromeos/dbus/dbus_thread_manager.h"
14 #include "chromeos/chromeos_switches.h"
hashimoto 2012/08/12 15:00:09 nit: This line should come before chromeos/dbus
stevenjb 2012/08/13 16:46:45 Done.
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 16
15 namespace chromeos { 17 namespace chromeos {
16 18
17 namespace { 19 namespace {
18 20
19 class TestObserver : public NetworkSmsHandler::Observer { 21 class TestObserver : public NetworkSmsHandler::Observer {
20 public: 22 public:
21 TestObserver() {} 23 TestObserver() {}
22 virtual ~TestObserver() {} 24 virtual ~TestObserver() {}
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 58
57 virtual void TearDown() OVERRIDE { 59 virtual void TearDown() OVERRIDE {
58 DBusThreadManager::Shutdown(); 60 DBusThreadManager::Shutdown();
59 } 61 }
60 62
61 protected: 63 protected:
62 MessageLoopForUI message_loop_; 64 MessageLoopForUI message_loop_;
63 }; 65 };
64 66
65 TEST_F(NetworkSmsHandlerTest, SmsHandlerDbusStub) { 67 TEST_F(NetworkSmsHandlerTest, SmsHandlerDbusStub) {
68 CommandLine* command_line = CommandLine::ForCurrentProcess();
69 command_line->AppendSwitch(chromeos::switches::kSmsTestMessages);
hashimoto 2012/08/12 15:00:09 Please add a brief description comment about why t
stevenjb 2012/08/13 16:46:45 Done.
70
66 // This relies on the stub dbus implementations for FlimflamManagerClient, 71 // This relies on the stub dbus implementations for FlimflamManagerClient,
67 // FlimflamDeviceClient, GsmSMSClient, ModemMessagingClient and SMSClient. 72 // FlimflamDeviceClient, GsmSMSClient, ModemMessagingClient and SMSClient.
68 // 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
69 // first test message until RequestUpdate has been called. 74 // first test message until RequestUpdate has been called.
70 scoped_ptr<NetworkSmsHandler> sms_handler(new NetworkSmsHandler()); 75 scoped_ptr<NetworkSmsHandler> sms_handler(new NetworkSmsHandler());
71 scoped_ptr<TestObserver> test_observer(new TestObserver()); 76 scoped_ptr<TestObserver> test_observer(new TestObserver());
72 sms_handler->AddObserver(test_observer.get()); 77 sms_handler->AddObserver(test_observer.get());
73 sms_handler->Init(); 78 sms_handler->Init();
74 message_loop_.RunAllPending(); 79 message_loop_.RunAllPending();
75 EXPECT_EQ(test_observer->message_count(), 0); 80 EXPECT_EQ(test_observer->message_count(), 0);
76 81
77 // Test that no messages have been received yet 82 // Test that no messages have been received yet
78 const std::set<std::string>& messages(test_observer->messages()); 83 const std::set<std::string>& messages(test_observer->messages());
79 // Note: The following string corresponds to values in 84 // Note: The following string corresponds to values in
80 // ModemMessagingClientStubImpl and SmsClientStubImpl. 85 // ModemMessagingClientStubImpl and SmsClientStubImpl.
81 const char kMessage1[] = "SMSClientStubImpl: Test Message: /SMS/0"; 86 const char kMessage1[] = "SMSClientStubImpl: Test Message: /SMS/0";
82 EXPECT_EQ(messages.find(kMessage1), messages.end()); 87 EXPECT_EQ(messages.find(kMessage1), messages.end());
83 88
84 // Test for messages delivered by signals. 89 // Test for messages delivered by signals.
85 test_observer->ClearMessages(); 90 test_observer->ClearMessages();
86 sms_handler->RequestUpdate(); 91 sms_handler->RequestUpdate();
87 message_loop_.RunAllPending(); 92 message_loop_.RunAllPending();
88 EXPECT_GE(test_observer->message_count(), 1); 93 EXPECT_GE(test_observer->message_count(), 1);
89 EXPECT_NE(messages.find(kMessage1), messages.end()); 94 EXPECT_NE(messages.find(kMessage1), messages.end());
90 } 95 }
91 96
92 } // namespace chromeos 97 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698