OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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. |
| 4 |
| 5 #include "chrome/browser/sync/util/channel.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 |
| 8 struct TestEvent { |
| 9 explicit TestEvent(int foo) : data(foo) {} |
| 10 int data; |
| 11 }; |
| 12 |
| 13 class TestObserver : public browser_sync::ChannelEventHandler<TestEvent> { |
| 14 public: |
| 15 virtual void HandleChannelEvent(const TestEvent& event) { |
| 16 delete hookup; |
| 17 hookup = 0; |
| 18 } |
| 19 |
| 20 browser_sync::ChannelHookup<TestEvent>* hookup; |
| 21 }; |
| 22 |
| 23 TEST(ChannelTest, RemoveOnNotify) { |
| 24 browser_sync::Channel<TestEvent> channel; |
| 25 TestObserver observer; |
| 26 |
| 27 observer.hookup = channel.AddObserver(&observer); |
| 28 |
| 29 ASSERT_TRUE(0 != observer.hookup); |
| 30 channel.Notify(TestEvent(1)); |
| 31 ASSERT_EQ(0, observer.hookup); |
| 32 } |
OLD | NEW |