| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/notifications/notification_platform_bridge_linux.h" | 5 #include "chrome/browser/notifications/notification_platform_bridge_linux.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 ACTION_P(OnGetCapabilities, capabilities) { | 38 ACTION_P(OnGetCapabilities, capabilities) { |
| 39 // MockObjectProxy::CallMethodAndBlock will wrap the return value in | 39 // MockObjectProxy::CallMethodAndBlock will wrap the return value in |
| 40 // a unique_ptr. | 40 // a unique_ptr. |
| 41 dbus::Response* response = dbus::Response::CreateEmpty().release(); | 41 dbus::Response* response = dbus::Response::CreateEmpty().release(); |
| 42 dbus::MessageWriter writer(response); | 42 dbus::MessageWriter writer(response); |
| 43 writer.AppendArrayOfStrings(capabilities); | 43 writer.AppendArrayOfStrings(capabilities); |
| 44 return response; | 44 return response; |
| 45 } | 45 } |
| 46 | 46 |
| 47 ACTION_P(OnGetServerInformation, spec_version) { |
| 48 dbus::Response* response = dbus::Response::CreateEmpty().release(); |
| 49 dbus::MessageWriter writer(response); |
| 50 writer.AppendString(""); // name |
| 51 writer.AppendString(""); // vendor |
| 52 writer.AppendString(""); // version |
| 53 writer.AppendString(spec_version); |
| 54 return response; |
| 55 } |
| 56 |
| 47 ACTION_P(OnNotify, id) { | 57 ACTION_P(OnNotify, id) { |
| 48 // The "Notify" message must have type (susssasa{sv}i). | 58 // The "Notify" message must have type (susssasa{sv}i). |
| 49 // https://developer.gnome.org/notification-spec/#command-notify | 59 // https://developer.gnome.org/notification-spec/#command-notify |
| 50 dbus::MethodCall* method_call = arg0; | 60 dbus::MethodCall* method_call = arg0; |
| 51 dbus::MessageReader reader(method_call); | 61 dbus::MessageReader reader(method_call); |
| 52 std::string str; | 62 std::string str; |
| 53 uint32_t uint32; | 63 uint32_t uint32; |
| 54 int32_t int32; | 64 int32_t int32; |
| 55 EXPECT_TRUE(reader.PopString(&str)); | 65 EXPECT_TRUE(reader.PopString(&str)); |
| 56 EXPECT_TRUE(reader.PopUint32(&uint32)); | 66 EXPECT_TRUE(reader.PopUint32(&uint32)); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 145 |
| 136 EXPECT_CALL(*mock_bus_.get(), | 146 EXPECT_CALL(*mock_bus_.get(), |
| 137 GetObjectProxy(kFreedesktopNotificationsName, | 147 GetObjectProxy(kFreedesktopNotificationsName, |
| 138 dbus::ObjectPath(kFreedesktopNotificationsPath))) | 148 dbus::ObjectPath(kFreedesktopNotificationsPath))) |
| 139 .WillOnce(Return(mock_notification_proxy_.get())); | 149 .WillOnce(Return(mock_notification_proxy_.get())); |
| 140 | 150 |
| 141 EXPECT_CALL(*mock_notification_proxy_.get(), | 151 EXPECT_CALL(*mock_notification_proxy_.get(), |
| 142 MockCallMethodAndBlock(Calls("GetCapabilities"), _)) | 152 MockCallMethodAndBlock(Calls("GetCapabilities"), _)) |
| 143 .WillOnce(OnGetCapabilities(std::vector<std::string>())); | 153 .WillOnce(OnGetCapabilities(std::vector<std::string>())); |
| 144 | 154 |
| 155 EXPECT_CALL(*mock_notification_proxy_.get(), |
| 156 MockCallMethodAndBlock(Calls("GetServerInformation"), _)) |
| 157 .WillOnce(OnGetServerInformation("1.2")); |
| 158 |
| 145 EXPECT_CALL( | 159 EXPECT_CALL( |
| 146 *mock_notification_proxy_.get(), | 160 *mock_notification_proxy_.get(), |
| 147 ConnectToSignal(kFreedesktopNotificationsName, "ActionInvoked", _, _)) | 161 ConnectToSignal(kFreedesktopNotificationsName, "ActionInvoked", _, _)) |
| 148 .WillOnce(RegisterSignalCallback(&action_invoked_callback_)); | 162 .WillOnce(RegisterSignalCallback(&action_invoked_callback_)); |
| 149 | 163 |
| 150 EXPECT_CALL(*mock_notification_proxy_.get(), | 164 EXPECT_CALL(*mock_notification_proxy_.get(), |
| 151 ConnectToSignal(kFreedesktopNotificationsName, | 165 ConnectToSignal(kFreedesktopNotificationsName, |
| 152 "NotificationClosed", _, _)) | 166 "NotificationClosed", _, _)) |
| 153 .WillOnce(RegisterSignalCallback(¬ification_closed_callback_)); | 167 .WillOnce(RegisterSignalCallback(¬ification_closed_callback_)); |
| 154 | 168 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 .WillOnce(OnNotify(1)); | 202 .WillOnce(OnNotify(1)); |
| 189 notification_bridge_linux_->Display(NotificationCommon::PERSISTENT, "", "", | 203 notification_bridge_linux_->Display(NotificationCommon::PERSISTENT, "", "", |
| 190 false, | 204 false, |
| 191 CreateNotification("id1", "", "", "")); | 205 CreateNotification("id1", "", "", "")); |
| 192 | 206 |
| 193 EXPECT_CALL(*mock_notification_proxy_.get(), | 207 EXPECT_CALL(*mock_notification_proxy_.get(), |
| 194 MockCallMethodAndBlock(Calls("CloseNotification"), _)) | 208 MockCallMethodAndBlock(Calls("CloseNotification"), _)) |
| 195 .WillOnce(OnCloseNotification()); | 209 .WillOnce(OnCloseNotification()); |
| 196 notification_bridge_linux_->Close("", ""); | 210 notification_bridge_linux_->Close("", ""); |
| 197 } | 211 } |
| OLD | NEW |