Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // This file provides tests for individual messages. It tests |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 6 | // NetlinkMessageFactory's ability to create specific message types and it |
| 7 | // tests the various NetlinkMessage types' ability to parse those |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 8 | // messages. |
| 9 | |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 10 | // This file tests the public interface to NetlinkManager. |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 11 | #include "shill/netlink_manager.h" |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 12 | |
| 13 | #include <gmock/gmock.h> |
| 14 | #include <gtest/gtest.h> |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 15 | |
Wade Guthrie | cc53f23 | 2013-03-05 13:22:23 -0800 | [diff] [blame] | 16 | #include "shill/mock_netlink_socket.h" |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 17 | #include "shill/nl80211_message.h" |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 18 | |
| 19 | using base::Bind; |
| 20 | using base::Unretained; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 21 | using testing::_; |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 22 | using testing::Invoke; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 23 | using testing::Return; |
| 24 | using testing::Test; |
| 25 | |
| 26 | namespace shill { |
| 27 | |
| 28 | namespace { |
| 29 | |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 30 | // These data blocks have been collected by shill using NetlinkManager while, |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 31 | // simultaneously (and manually) comparing shill output with that of the 'iw' |
| 32 | // code from which it was derived. The test strings represent the raw packet |
| 33 | // data coming from the kernel. The comments above each of these strings is |
| 34 | // the markup that "iw" outputs for ech of these packets. |
| 35 | |
| 36 | // These constants are consistent throughout the packets, below. |
| 37 | |
Wade Guthrie | bdcdaa7 | 2013-03-04 12:47:12 -0800 | [diff] [blame] | 38 | const uint16_t kNl80211FamilyId = 0x13; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 39 | |
| 40 | // wlan0 (phy #0): disconnected (by AP) reason: 2: Previous authentication no |
| 41 | // longer valid |
| 42 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 43 | const unsigned char kNL80211_CMD_DISCONNECT[] = { |
| 44 | 0x30, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, |
| 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 46 | 0x30, 0x01, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, |
| 47 | 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x03, 0x00, |
| 48 | 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0x36, 0x00, |
| 49 | 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x47, 0x00, |
| 50 | }; |
| 51 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 52 | const char kGetFamilyCommandString[] = "CTRL_CMD_GETFAMILY"; |
| 53 | |
Wade Guthrie | b1ec860 | 2012-10-18 17:26:14 -0700 | [diff] [blame] | 54 | } // namespace |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 55 | |
Wade Guthrie | cc53f23 | 2013-03-05 13:22:23 -0800 | [diff] [blame] | 56 | bool MockNetlinkSocket::SendMessage(const ByteString &out_string) { |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 57 | return true; |
| 58 | } |
| 59 | |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 60 | class NetlinkManagerTest : public Test { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 61 | public: |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 62 | NetlinkManagerTest() : netlink_manager_(NetlinkManager::GetInstance()) { |
| 63 | netlink_manager_->message_types_[Nl80211Message::kMessageTypeString] |
| 64 | .family_id = kNl80211FamilyId; |
| 65 | netlink_manager_->message_factory_.AddFactoryMethod( |
Wade Guthrie | 12f113a | 2013-03-12 17:15:46 -0700 | [diff] [blame] | 66 | kNl80211FamilyId, Bind(&Nl80211Message::CreateMessage)); |
Wade Guthrie | bee87c2 | 2013-03-06 11:00:46 -0800 | [diff] [blame] | 67 | Nl80211Message::SetMessageType( |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 68 | netlink_manager_->GetMessageType(Nl80211Message::kMessageTypeString)); |
Wade Guthrie | bee87c2 | 2013-03-06 11:00:46 -0800 | [diff] [blame] | 69 | } |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 70 | |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 71 | ~NetlinkManagerTest() { |
| 72 | // NetlinkManager is a singleton, the sock_ field *MUST* be cleared |
| 73 | // before "NetlinkManagerTest::socket_" gets invalidated, otherwise |
Han Shen | 4afba20 | 2012-12-17 08:48:35 -0800 | [diff] [blame] | 74 | // later tests will refer to a corrupted memory. |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 75 | netlink_manager_->sock_ = NULL; |
Han Shen | 4afba20 | 2012-12-17 08:48:35 -0800 | [diff] [blame] | 76 | } |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 77 | |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 78 | void SetupNetlinkManagerObject() { |
| 79 | EXPECT_NE(reinterpret_cast<NetlinkManager *>(NULL), netlink_manager_); |
| 80 | netlink_manager_->sock_ = &socket_; |
| 81 | EXPECT_TRUE(netlink_manager_->Init()); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 82 | } |
| 83 | |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 84 | protected: |
| 85 | class MockHandler80211 { |
| 86 | public: |
| 87 | MockHandler80211() : |
| 88 | on_netlink_message_(base::Bind(&MockHandler80211::OnNetlinkMessage, |
| 89 | base::Unretained(this))) {} |
| 90 | MOCK_METHOD1(OnNetlinkMessage, void(const NetlinkMessage &msg)); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 91 | const NetlinkManager::NetlinkMessageHandler &on_netlink_message() const { |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 92 | return on_netlink_message_; |
| 93 | } |
| 94 | private: |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 95 | NetlinkManager::NetlinkMessageHandler on_netlink_message_; |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 96 | DISALLOW_COPY_AND_ASSIGN(MockHandler80211); |
| 97 | }; |
| 98 | |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 99 | NetlinkManager *netlink_manager_; |
Wade Guthrie | cc53f23 | 2013-03-05 13:22:23 -0800 | [diff] [blame] | 100 | MockNetlinkSocket socket_; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 101 | }; |
| 102 | |
Wade Guthrie | bee87c2 | 2013-03-06 11:00:46 -0800 | [diff] [blame] | 103 | // TODO(wdg): Add a test for multi-part messages. crbug.com/224652 |
| 104 | // TODO(wdg): Add a test for GetFaimily. crbug.com/224649 |
| 105 | // TODO(wdg): Add a test for OnNewFamilyMessage. crbug.com/222486 |
Wade Guthrie | 12f113a | 2013-03-12 17:15:46 -0700 | [diff] [blame] | 106 | // TODO(wdg): Add a test for GetMessageType |
Wade Guthrie | bee87c2 | 2013-03-06 11:00:46 -0800 | [diff] [blame] | 107 | // TODO(wdg): Add a test for SubscribeToEvents (verify that it handles bad input |
| 108 | // appropriately, and that it calls NetlinkSocket::SubscribeToEvents if input |
| 109 | // is good.) |
| 110 | |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 111 | TEST_F(NetlinkManagerTest, BroadcastHandlerTest) { |
| 112 | SetupNetlinkManagerObject(); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 113 | |
| 114 | nlmsghdr *message = const_cast<nlmsghdr *>( |
| 115 | reinterpret_cast<const nlmsghdr *>(kNL80211_CMD_DISCONNECT)); |
| 116 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 117 | MockHandler80211 handler1; |
| 118 | MockHandler80211 handler2; |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 119 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 120 | // Simple, 1 handler, case. |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 121 | EXPECT_CALL(handler1, OnNetlinkMessage(_)).Times(1); |
Wade Guthrie | 12f113a | 2013-03-12 17:15:46 -0700 | [diff] [blame] | 122 | EXPECT_FALSE( |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 123 | netlink_manager_->FindBroadcastHandler(handler1.on_netlink_message())); |
| 124 | netlink_manager_->AddBroadcastHandler(handler1.on_netlink_message()); |
Wade Guthrie | 12f113a | 2013-03-12 17:15:46 -0700 | [diff] [blame] | 125 | EXPECT_TRUE( |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 126 | netlink_manager_->FindBroadcastHandler(handler1.on_netlink_message())); |
| 127 | netlink_manager_->OnNlMessageReceived(message); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 128 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 129 | // Add a second handler. |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 130 | EXPECT_CALL(handler1, OnNetlinkMessage(_)).Times(1); |
| 131 | EXPECT_CALL(handler2, OnNetlinkMessage(_)).Times(1); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 132 | netlink_manager_->AddBroadcastHandler(handler2.on_netlink_message()); |
| 133 | netlink_manager_->OnNlMessageReceived(message); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 134 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 135 | // Verify that a handler can't be added twice. |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 136 | EXPECT_CALL(handler1, OnNetlinkMessage(_)).Times(1); |
| 137 | EXPECT_CALL(handler2, OnNetlinkMessage(_)).Times(1); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 138 | netlink_manager_->AddBroadcastHandler(handler1.on_netlink_message()); |
| 139 | netlink_manager_->OnNlMessageReceived(message); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 140 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 141 | // Check that we can remove a handler. |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 142 | EXPECT_CALL(handler1, OnNetlinkMessage(_)).Times(0); |
| 143 | EXPECT_CALL(handler2, OnNetlinkMessage(_)).Times(1); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 144 | EXPECT_TRUE(netlink_manager_->RemoveBroadcastHandler( |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 145 | handler1.on_netlink_message())); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 146 | netlink_manager_->OnNlMessageReceived(message); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 147 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 148 | // Check that re-adding the handler goes smoothly. |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 149 | EXPECT_CALL(handler1, OnNetlinkMessage(_)).Times(1); |
| 150 | EXPECT_CALL(handler2, OnNetlinkMessage(_)).Times(1); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 151 | netlink_manager_->AddBroadcastHandler(handler1.on_netlink_message()); |
| 152 | netlink_manager_->OnNlMessageReceived(message); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 153 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 154 | // Check that ClearBroadcastHandlers works. |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 155 | netlink_manager_->ClearBroadcastHandlers(); |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 156 | EXPECT_CALL(handler1, OnNetlinkMessage(_)).Times(0); |
| 157 | EXPECT_CALL(handler2, OnNetlinkMessage(_)).Times(0); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 158 | netlink_manager_->OnNlMessageReceived(message); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 161 | TEST_F(NetlinkManagerTest, MessageHandlerTest) { |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 162 | // Setup. |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 163 | SetupNetlinkManagerObject(); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 164 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 165 | MockHandler80211 handler_broadcast; |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 166 | EXPECT_TRUE(netlink_manager_->AddBroadcastHandler( |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 167 | handler_broadcast.on_netlink_message())); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 168 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 169 | Nl80211Message sent_message_1(CTRL_CMD_GETFAMILY, kGetFamilyCommandString); |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 170 | MockHandler80211 handler_sent_1; |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 171 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 172 | Nl80211Message sent_message_2(CTRL_CMD_GETFAMILY, kGetFamilyCommandString); |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 173 | MockHandler80211 handler_sent_2; |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 174 | |
| 175 | // Set up the received message as a response to sent_message_1. |
| 176 | scoped_array<unsigned char> message_memory( |
| 177 | new unsigned char[sizeof(kNL80211_CMD_DISCONNECT)]); |
| 178 | memcpy(message_memory.get(), kNL80211_CMD_DISCONNECT, |
| 179 | sizeof(kNL80211_CMD_DISCONNECT)); |
| 180 | nlmsghdr *received_message = |
| 181 | reinterpret_cast<nlmsghdr *>(message_memory.get()); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 182 | |
| 183 | // Now, we can start the actual test... |
| 184 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 185 | // Verify that generic handler gets called for a message when no |
| 186 | // message-specific handler has been installed. |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 187 | EXPECT_CALL(handler_broadcast, OnNetlinkMessage(_)).Times(1); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 188 | netlink_manager_->OnNlMessageReceived(received_message); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 189 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 190 | // Send the message and give our handler. Verify that we get called back. |
Wade Guthrie | 92d0636 | 2013-04-25 15:41:30 -0700 | [diff] [blame] | 191 | EXPECT_TRUE(netlink_manager_->SendMessage( |
| 192 | &sent_message_1, handler_sent_1.on_netlink_message())); |
Christopher Wiley | 393b93f | 2012-11-08 17:30:58 -0800 | [diff] [blame] | 193 | // Make it appear that this message is in response to our sent message. |
| 194 | received_message->nlmsg_seq = socket_.GetLastSequenceNumber(); |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 195 | EXPECT_CALL(handler_sent_1, OnNetlinkMessage(_)).Times(1); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 196 | netlink_manager_->OnNlMessageReceived(received_message); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 197 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 198 | // Verify that broadcast handler is called for the message after the |
| 199 | // message-specific handler is called once. |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 200 | EXPECT_CALL(handler_broadcast, OnNetlinkMessage(_)).Times(1); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 201 | netlink_manager_->OnNlMessageReceived(received_message); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 202 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 203 | // Install and then uninstall message-specific handler; verify broadcast |
| 204 | // handler is called on message receipt. |
Wade Guthrie | 92d0636 | 2013-04-25 15:41:30 -0700 | [diff] [blame] | 205 | EXPECT_TRUE(netlink_manager_->SendMessage( |
| 206 | &sent_message_1, handler_sent_1.on_netlink_message())); |
Christopher Wiley | 393b93f | 2012-11-08 17:30:58 -0800 | [diff] [blame] | 207 | received_message->nlmsg_seq = socket_.GetLastSequenceNumber(); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 208 | EXPECT_TRUE(netlink_manager_->RemoveMessageHandler(sent_message_1)); |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 209 | EXPECT_CALL(handler_broadcast, OnNetlinkMessage(_)).Times(1); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 210 | netlink_manager_->OnNlMessageReceived(received_message); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 211 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 212 | // Install handler for different message; verify that broadcast handler is |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 213 | // called for _this_ message. |
Wade Guthrie | 92d0636 | 2013-04-25 15:41:30 -0700 | [diff] [blame] | 214 | EXPECT_TRUE(netlink_manager_->SendMessage( |
| 215 | &sent_message_2, handler_sent_2.on_netlink_message())); |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 216 | EXPECT_CALL(handler_broadcast, OnNetlinkMessage(_)).Times(1); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 217 | netlink_manager_->OnNlMessageReceived(received_message); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 218 | |
Wade Guthrie | 71cb0a7 | 2013-02-27 10:27:18 -0800 | [diff] [blame] | 219 | // Change the ID for the message to that of the second handler; verify that |
| 220 | // the appropriate handler is called for _that_ message. |
Christopher Wiley | 393b93f | 2012-11-08 17:30:58 -0800 | [diff] [blame] | 221 | received_message->nlmsg_seq = socket_.GetLastSequenceNumber(); |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 222 | EXPECT_CALL(handler_sent_2, OnNetlinkMessage(_)).Times(1); |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 223 | netlink_manager_->OnNlMessageReceived(received_message); |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 224 | } |
| 225 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 226 | } // namespace shill |