| 71 | }; |
| 72 | |
| 73 | TEST(ObserverListTest, BasicTest) { |
| 74 | ObserverList<Foo> observer_list; |
| 75 | Adder a(1), b(-1), c(1), d(-1), e(-1); |
| 76 | Disrupter evil(&observer_list, &c); |
| 77 | |
| 78 | observer_list.AddObserver(&a); |
| 79 | observer_list.AddObserver(&b); |
| 80 | |
| 81 | FOR_EACH_OBSERVER(Foo, observer_list, Observe(10)); |
| 82 | |
| 83 | observer_list.AddObserver(&evil); |
| 84 | observer_list.AddObserver(&c); |
| 85 | observer_list.AddObserver(&d); |
| 86 | |
| 87 | // Removing an observer not in the list should do nothing. |
| 88 | observer_list.RemoveObserver(&e); |
| 89 | |
| 90 | FOR_EACH_OBSERVER(Foo, observer_list, Observe(10)); |
| 91 | |
| 92 | EXPECT_EQ(20, a.total); |
| 93 | EXPECT_EQ(-20, b.total); |
| 94 | EXPECT_EQ(0, c.total); |
| 95 | EXPECT_EQ(-10, d.total); |
| 96 | EXPECT_EQ(0, e.total); |
| 97 | } |
| 98 | |
| 99 | TEST(ObserverListTest, Existing) { |
| 100 | ObserverList<Foo> observer_list(ObserverList<Foo>::NOTIFY_EXISTING_ONLY); |
nothing calls this directly
no test coverage detected