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

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

Issue 2867203002: Linux native notifications: fix Tsan failure in NotifyAndCloseFormat (Closed)
Patch Set: 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
« 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 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 EXPECT_CALL( 145 EXPECT_CALL(
146 *mock_notification_proxy_.get(), 146 *mock_notification_proxy_.get(),
147 ConnectToSignal(kFreedesktopNotificationsName, "ActionInvoked", _, _)) 147 ConnectToSignal(kFreedesktopNotificationsName, "ActionInvoked", _, _))
148 .WillOnce(RegisterSignalCallback(&action_invoked_callback_)); 148 .WillOnce(RegisterSignalCallback(&action_invoked_callback_));
149 149
150 EXPECT_CALL(*mock_notification_proxy_.get(), 150 EXPECT_CALL(*mock_notification_proxy_.get(),
151 ConnectToSignal(kFreedesktopNotificationsName, 151 ConnectToSignal(kFreedesktopNotificationsName,
152 "NotificationClosed", _, _)) 152 "NotificationClosed", _, _))
153 .WillOnce(RegisterSignalCallback(&notification_closed_callback_)); 153 .WillOnce(RegisterSignalCallback(&notification_closed_callback_));
154
155 notification_bridge_linux_ =
156 base::WrapUnique(new NotificationPlatformBridgeLinux(mock_bus_));
157 } 154 }
158 155
159 void TearDown() override { 156 void TearDown() override {
160 EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock()); 157 EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock());
161 notification_bridge_linux_->CleanUp(); 158 notification_bridge_linux_->CleanUp();
162 content::RunAllBlockingPoolTasksUntilIdle(); 159 content::RunAllBlockingPoolTasksUntilIdle();
163 notification_bridge_linux_.reset(); 160 notification_bridge_linux_.reset();
164 mock_notification_proxy_ = nullptr; 161 mock_notification_proxy_ = nullptr;
165 mock_bus_ = nullptr; 162 mock_bus_ = nullptr;
166 } 163 }
167 164
168 protected: 165 protected:
166 void CreateNotificationBridgeLinux() {
167 notification_bridge_linux_ =
168 base::WrapUnique(new NotificationPlatformBridgeLinux(mock_bus_));
169 }
170
169 content::TestBrowserThreadBundle thread_bundle_; 171 content::TestBrowserThreadBundle thread_bundle_;
170 172
171 scoped_refptr<dbus::MockBus> mock_bus_; 173 scoped_refptr<dbus::MockBus> mock_bus_;
172 scoped_refptr<dbus::MockObjectProxy> mock_notification_proxy_; 174 scoped_refptr<dbus::MockObjectProxy> mock_notification_proxy_;
173 175
174 base::Callback<void(dbus::Signal*)> action_invoked_callback_; 176 base::Callback<void(dbus::Signal*)> action_invoked_callback_;
175 base::Callback<void(dbus::Signal*)> notification_closed_callback_; 177 base::Callback<void(dbus::Signal*)> notification_closed_callback_;
176 178
177 std::unique_ptr<NotificationPlatformBridgeLinux> notification_bridge_linux_; 179 std::unique_ptr<NotificationPlatformBridgeLinux> notification_bridge_linux_;
178 180
179 private: 181 private:
180 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeLinuxTest); 182 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeLinuxTest);
181 }; 183 };
182 184
183 TEST_F(NotificationPlatformBridgeLinuxTest, SetUpAndTearDown) {} 185 TEST_F(NotificationPlatformBridgeLinuxTest, SetUpAndTearDown) {
186 CreateNotificationBridgeLinux();
187 }
184 188
185 // Frequently triggers a data race. Disabled as flaky: https://crbug.com/719485 189 TEST_F(NotificationPlatformBridgeLinuxTest, NotifyAndCloseFormat) {
186 TEST_F(NotificationPlatformBridgeLinuxTest, DISABLED_NotifyAndCloseFormat) {
187 EXPECT_CALL(*mock_notification_proxy_.get(), 190 EXPECT_CALL(*mock_notification_proxy_.get(),
188 MockCallMethodAndBlock(Calls("Notify"), _)) 191 MockCallMethodAndBlock(Calls("Notify"), _))
189 .WillOnce(OnNotify(1)); 192 .WillOnce(OnNotify(1));
193 EXPECT_CALL(*mock_notification_proxy_.get(),
194 MockCallMethodAndBlock(Calls("CloseNotification"), _))
195 .WillOnce(OnCloseNotification());
196
197 CreateNotificationBridgeLinux();
190 notification_bridge_linux_->Display(NotificationCommon::PERSISTENT, "", "", 198 notification_bridge_linux_->Display(NotificationCommon::PERSISTENT, "", "",
191 false, 199 false,
192 CreateNotification("id1", "", "", "")); 200 CreateNotification("id1", "", "", ""));
193
194 EXPECT_CALL(*mock_notification_proxy_.get(),
195 MockCallMethodAndBlock(Calls("CloseNotification"), _))
196 .WillOnce(OnCloseNotification());
197 notification_bridge_linux_->Close("", ""); 201 notification_bridge_linux_->Close("", "");
198 } 202 }
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