Don't add an aura tooltip to bubble close buttons on Windows.
[chromium-blink-merge.git] / ash / shelf / scoped_observer_with_duplicated_sources_unittest.cc
blob82d2b83b78b59f5e781118fce9944066a952b828
1 // Copyright 2013 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 "ash/shelf/scoped_observer_with_duplicated_sources.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 class TestObserver {
11 public:
12 TestObserver() {}
13 ~TestObserver() {}
15 private:
16 DISALLOW_COPY_AND_ASSIGN(TestObserver);
19 class TestSource {
20 public:
21 TestSource() : observer_count_(0) {}
22 ~TestSource() {}
24 void AddObserver(TestObserver* observer) {
25 observer_count_++;
27 void RemoveObserver(TestObserver* observer) {
28 observer_count_--;
31 int GetObserverCount() {
32 return observer_count_;
35 private:
36 int observer_count_;
38 DISALLOW_COPY_AND_ASSIGN(TestSource);
41 TEST(ScopedObserverWithDuplicatedSourcesTest, DuplicatedSource) {
42 TestObserver observer;
43 TestSource source1;
44 TestSource source2;
46 ScopedObserverWithDuplicatedSources<TestSource, TestObserver>
47 observers(&observer);
48 EXPECT_EQ(0, source1.GetObserverCount());
49 EXPECT_FALSE(observers.IsObserving(&source1));
50 EXPECT_EQ(0, source2.GetObserverCount());
51 EXPECT_FALSE(observers.IsObserving(&source2));
53 // Add |source1|.
54 observers.Add(&source1);
55 EXPECT_EQ(1, source1.GetObserverCount());
56 EXPECT_TRUE(observers.IsObserving(&source1));
57 // AddObserver of TestSource is called only once.
58 observers.Add(&source1);
59 EXPECT_EQ(1, source1.GetObserverCount());
60 EXPECT_TRUE(observers.IsObserving(&source1));
62 // Add |source2|.
63 observers.Add(&source2);
64 EXPECT_EQ(1, source2.GetObserverCount());
65 EXPECT_TRUE(observers.IsObserving(&source2));
67 // Remove |source1|.
68 observers.Remove(&source1);
69 EXPECT_EQ(1, source1.GetObserverCount());
70 EXPECT_TRUE(observers.IsObserving(&source1));
72 // Remove |source2|.
73 observers.Remove(&source2);
74 EXPECT_EQ(0, source2.GetObserverCount());
75 EXPECT_FALSE(observers.IsObserving(&source2));
77 // Remove |source1| again.
78 observers.Remove(&source1);
79 // In this time, |observer| is removed from |source1|.
80 EXPECT_EQ(0, source1.GetObserverCount());
81 EXPECT_FALSE(observers.IsObserving(&source1));