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

Side by Side Diff: chrome/browser/notifications/notification_platform_bridge_linux_unittest.cc

Issue 2856753002: Linux native notifications: Add server capabilities metrics (Closed)
Patch Set: Rebase Created 3 years, 7 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
OLDNEW
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 9
9 #include "base/callback.h" 10 #include "base/callback.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "chrome/browser/notifications/notification.h" 14 #include "chrome/browser/notifications/notification.h"
14 #include "content/public/test/test_browser_thread_bundle.h" 15 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "content/public/test/test_utils.h" 16 #include "content/public/test/test_utils.h"
16 #include "dbus/mock_bus.h" 17 #include "dbus/mock_bus.h"
17 #include "dbus/mock_object_proxy.h" 18 #include "dbus/mock_object_proxy.h"
18 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace { 22 namespace {
22 23
23 const char kFreedesktopNotificationsName[] = "org.freedesktop.Notifications"; 24 const char kFreedesktopNotificationsName[] = "org.freedesktop.Notifications";
24 const char kFreedesktopNotificationsPath[] = "/org/freedesktop/Notifications"; 25 const char kFreedesktopNotificationsPath[] = "/org/freedesktop/Notifications";
25 26
26 ACTION_P(RegisterSignalCallback, callback_addr) { 27 ACTION_P(RegisterSignalCallback, callback_addr) {
27 *callback_addr = arg2; 28 *callback_addr = arg2;
28 arg3.Run("" /* interface_name */, "" /* signal_name */, true /* success */); 29 arg3.Run("" /* interface_name */, "" /* signal_name */, true /* success */);
29 } 30 }
30 31
32 ACTION_P(OnGetCapabilities, capabilities) {
33 // MockObjectProxy::CallMethodAndBlock will wrap the return value in
34 // a unique_ptr.
35 dbus::Response* response = dbus::Response::CreateEmpty().release();
36 dbus::MessageWriter writer(response);
37 writer.AppendArrayOfStrings(capabilities);
38 return response;
39 }
40
31 } // namespace 41 } // namespace
32 42
33 class NotificationPlatformBridgeLinuxTest : public testing::Test { 43 class NotificationPlatformBridgeLinuxTest : public testing::Test {
34 public: 44 public:
35 NotificationPlatformBridgeLinuxTest() = default; 45 NotificationPlatformBridgeLinuxTest() = default;
36 ~NotificationPlatformBridgeLinuxTest() override = default; 46 ~NotificationPlatformBridgeLinuxTest() override = default;
37 47
38 void SetUp() override { 48 void SetUp() override {
39 mock_bus_ = new dbus::MockBus(dbus::Bus::Options()); 49 mock_bus_ = new dbus::MockBus(dbus::Bus::Options());
40 mock_notification_proxy_ = new testing::StrictMock<dbus::MockObjectProxy>( 50 mock_notification_proxy_ = new testing::StrictMock<dbus::MockObjectProxy>(
41 mock_bus_.get(), kFreedesktopNotificationsName, 51 mock_bus_.get(), kFreedesktopNotificationsName,
42 dbus::ObjectPath(kFreedesktopNotificationsPath)); 52 dbus::ObjectPath(kFreedesktopNotificationsPath));
43 53
44 EXPECT_CALL(*mock_bus_.get(), 54 EXPECT_CALL(*mock_bus_.get(),
45 GetObjectProxy(kFreedesktopNotificationsName, 55 GetObjectProxy(kFreedesktopNotificationsName,
46 dbus::ObjectPath(kFreedesktopNotificationsPath))) 56 dbus::ObjectPath(kFreedesktopNotificationsPath)))
47 .WillOnce(testing::Return(mock_notification_proxy_.get())); 57 .WillOnce(testing::Return(mock_notification_proxy_.get()));
48 58
49 EXPECT_CALL(*mock_notification_proxy_.get(), 59 EXPECT_CALL(*mock_notification_proxy_.get(),
60 MockCallMethodAndBlock(testing::_, testing::_))
61 .WillOnce(OnGetCapabilities(std::vector<std::string>()));
62
63 EXPECT_CALL(*mock_notification_proxy_.get(),
50 ConnectToSignal(kFreedesktopNotificationsName, "ActionInvoked", 64 ConnectToSignal(kFreedesktopNotificationsName, "ActionInvoked",
51 testing::_, testing::_)) 65 testing::_, testing::_))
52 .WillOnce(RegisterSignalCallback(&action_invoked_callback_)); 66 .WillOnce(RegisterSignalCallback(&action_invoked_callback_));
53 67
54 EXPECT_CALL(*mock_notification_proxy_.get(), 68 EXPECT_CALL(*mock_notification_proxy_.get(),
55 ConnectToSignal(kFreedesktopNotificationsName, 69 ConnectToSignal(kFreedesktopNotificationsName,
56 "NotificationClosed", testing::_, testing::_)) 70 "NotificationClosed", testing::_, testing::_))
57 .WillOnce(RegisterSignalCallback(&notification_closed_callback_)); 71 .WillOnce(RegisterSignalCallback(&notification_closed_callback_));
58 72
59 notification_bridge_linux_ = 73 notification_bridge_linux_ =
(...skipping 18 matching lines...) Expand all
78 base::Callback<void(dbus::Signal*)> action_invoked_callback_; 92 base::Callback<void(dbus::Signal*)> action_invoked_callback_;
79 base::Callback<void(dbus::Signal*)> notification_closed_callback_; 93 base::Callback<void(dbus::Signal*)> notification_closed_callback_;
80 94
81 std::unique_ptr<NotificationPlatformBridgeLinux> notification_bridge_linux_; 95 std::unique_ptr<NotificationPlatformBridgeLinux> notification_bridge_linux_;
82 96
83 private: 97 private:
84 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeLinuxTest); 98 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeLinuxTest);
85 }; 99 };
86 100
87 TEST_F(NotificationPlatformBridgeLinuxTest, SetUpAndTearDown) {} 101 TEST_F(NotificationPlatformBridgeLinuxTest, SetUpAndTearDown) {}
OLDNEW
« no previous file with comments | « chrome/browser/notifications/notification_platform_bridge_linux.cc ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698