Chromium Code Reviews| Index: chrome/browser/notifications/notification_platform_bridge_linux_unittest.cc |
| diff --git a/chrome/browser/notifications/notification_platform_bridge_linux_unittest.cc b/chrome/browser/notifications/notification_platform_bridge_linux_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eb5d9e5d9b4eac4d667b74e5d5eb9dd9d8b945fb |
| --- /dev/null |
| +++ b/chrome/browser/notifications/notification_platform_bridge_linux_unittest.cc |
| @@ -0,0 +1,87 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/notifications/notification_platform_bridge_linux.h" |
| + |
| +#include "base/callback.h" |
| +#include "base/logging.h" |
| +#include "base/memory/ptr_util.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/sequenced_task_runner.h" |
| +#include "chrome/browser/notifications/notification.h" |
| +#include "content/public/test/test_browser_thread_bundle.h" |
| +#include "content/public/test/test_utils.h" |
| +#include "dbus/mock_bus.h" |
| +#include "dbus/mock_object_proxy.h" |
| +#include "testing/gmock/include/gmock/gmock.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace { |
| + |
| +ACTION_P(RegisterSignalCallback, callback_addr) { |
| + *callback_addr = arg2; |
| + arg3.Run("", "", true); |
|
Peter Beverloo
2017/05/02 13:50:21
It would be good to annotate what the parameters m
Tom (Use chromium acct)
2017/05/02 21:23:16
Done.
|
| +} |
| + |
| +} // namespace |
| + |
| +class NotificationPlatformBridgeLinuxTest : public testing::Test { |
| + public: |
| + NotificationPlatformBridgeLinuxTest() {} |
|
Peter Beverloo
2017/05/02 13:50:21
nit: {} --> = default;
Could just leave out this
Tom (Use chromium acct)
2017/05/02 21:23:16
Done.
|
| + |
| + void SetUp() override { |
| + static const char kFreedesktopNotificationsName[] = |
| + "org.freedesktop.Notifications"; |
| + static const char kFreedesktopNotificationsPath[] = |
| + "/org/freedesktop/Notifications"; |
|
Peter Beverloo
2017/05/02 13:50:21
nit: usually we just put such constants in the ano
Tom (Use chromium acct)
2017/05/02 21:23:16
Done.
|
| + |
| + mock_bus_ = new dbus::MockBus(dbus::Bus::Options()); |
| + mock_notification_proxy_ = new testing::StrictMock<dbus::MockObjectProxy>( |
| + mock_bus_.get(), kFreedesktopNotificationsName, |
| + dbus::ObjectPath(kFreedesktopNotificationsPath)); |
| + |
| + EXPECT_CALL(*mock_bus_.get(), |
| + GetObjectProxy(kFreedesktopNotificationsName, |
| + dbus::ObjectPath(kFreedesktopNotificationsPath))) |
| + .WillOnce(testing::Return(mock_notification_proxy_.get())); |
| + |
| + EXPECT_CALL(*mock_notification_proxy_.get(), |
| + ConnectToSignal(kFreedesktopNotificationsName, "ActionInvoked", |
| + testing::_, testing::_)) |
| + .WillOnce(RegisterSignalCallback(&action_invoked_callback_)); |
| + |
| + EXPECT_CALL(*mock_notification_proxy_.get(), |
| + ConnectToSignal(kFreedesktopNotificationsName, |
| + "NotificationClosed", testing::_, testing::_)) |
| + .WillOnce(RegisterSignalCallback(¬ification_closed_callback_)); |
| + |
| + notification_bridge_linux_.reset( |
| + new NotificationPlatformBridgeLinux(mock_bus_)); |
| + } |
| + |
| + void TearDown() override { |
| + EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock()); |
| + notification_bridge_linux_->CleanUp(); |
| + content::RunAllBlockingPoolTasksUntilIdle(); |
| + notification_bridge_linux_.reset(); |
| + mock_notification_proxy_ = nullptr; |
| + mock_bus_ = nullptr; |
| + } |
| + |
| + protected: |
| + content::TestBrowserThreadBundle thread_bundle_; |
| + |
| + scoped_refptr<dbus::MockBus> mock_bus_; |
| + scoped_refptr<dbus::MockObjectProxy> mock_notification_proxy_; |
| + |
| + base::Callback<void(dbus::Signal*)> action_invoked_callback_; |
| + base::Callback<void(dbus::Signal*)> notification_closed_callback_; |
| + |
| + std::unique_ptr<NotificationPlatformBridgeLinux> notification_bridge_linux_; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeLinuxTest); |
| +}; |
| + |
| +TEST_F(NotificationPlatformBridgeLinuxTest, SetUpAndTearDown) {} |
|
Peter Beverloo
2017/05/02 13:50:21
What sort of tests do you have in mind?
Tom (Use chromium acct)
2017/05/02 21:23:16
* Verify format of the "Notify" message
* Verify f
Peter Beverloo
2017/05/03 00:31:26
Perfect :)
|