Revert of Build the Clang plugin on Windows. (patchset #6 id:100001 of https://codere...
[chromium-blink-merge.git] / ui / message_center / notification_delegate_unittest.cc
blob72a32418301b910857eb68e41f4db48785d44050
1 // Copyright 2014 The Chromium 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.
5 #include "ui/message_center/notification_delegate.h"
7 #include "base/basictypes.h"
8 #include "base/bind.h"
9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 namespace message_center {
15 class NotificationDelegateTest : public testing::Test {
16 public:
17 NotificationDelegateTest();
18 ~NotificationDelegateTest() override;
20 void ClickCallback();
22 int GetClickedCallbackAndReset();
24 private:
25 int callback_count_;
27 DISALLOW_COPY_AND_ASSIGN(NotificationDelegateTest);
30 NotificationDelegateTest::NotificationDelegateTest() : callback_count_(0) {}
32 NotificationDelegateTest::~NotificationDelegateTest() {}
34 void NotificationDelegateTest::ClickCallback() {
35 ++callback_count_;
38 int NotificationDelegateTest::GetClickedCallbackAndReset() {
39 int result = callback_count_;
40 callback_count_ = 0;
41 return result;
44 TEST_F(NotificationDelegateTest, ClickedDelegate) {
45 scoped_refptr<HandleNotificationClickedDelegate> delegate(
46 new HandleNotificationClickedDelegate(
47 base::Bind(&NotificationDelegateTest::ClickCallback,
48 base::Unretained(this))));
50 EXPECT_TRUE(delegate->HasClickedListener());
51 delegate->Click();
52 EXPECT_EQ(1, GetClickedCallbackAndReset());
54 // ButtonClick doesn't call the callback.
55 delegate->ButtonClick(0);
56 EXPECT_EQ(0, GetClickedCallbackAndReset());
59 TEST_F(NotificationDelegateTest, NullClickedDelegate) {
60 scoped_refptr<HandleNotificationClickedDelegate> delegate(
61 new HandleNotificationClickedDelegate(base::Closure()));
63 EXPECT_FALSE(delegate->HasClickedListener());
64 delegate->Click();
65 EXPECT_EQ(0, GetClickedCallbackAndReset());
67 delegate->ButtonClick(0);
68 EXPECT_EQ(0, GetClickedCallbackAndReset());