OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "config.h" |
| 6 #include "core/frame/ViewportChangeNotifier.h" |
| 7 |
| 8 #include <gtest/gtest.h> |
| 9 |
| 10 namespace WebCore { |
| 11 |
| 12 class TestListener: public ViewportChangeListener { |
| 13 public: |
| 14 static PassRefPtrWillBeRawPtr<TestListener> create() { return adoptRefWillBe
Noop(new TestListener()); } |
| 15 |
| 16 void viewportChanged() |
| 17 { |
| 18 m_listenerCalled = true; |
| 19 } |
| 20 |
| 21 TestListener() |
| 22 : m_listenerCalled(false) |
| 23 { |
| 24 } |
| 25 |
| 26 bool called() const { return m_listenerCalled; } |
| 27 |
| 28 private: |
| 29 bool m_listenerCalled; |
| 30 }; |
| 31 |
| 32 TEST(ViewportChangeNotifierTest, Basic) |
| 33 { |
| 34 OwnPtrWillBeRawPtr<ViewportChangeNotifier> notifier = ViewportChangeNotifier
::create(); |
| 35 RefPtrWillBeRawPtr<TestListener> listener = TestListener::create(); |
| 36 notifier->addListener(listener); |
| 37 ASSERT_FALSE(listener->called()); |
| 38 notifier->viewportChanged(); |
| 39 ASSERT_TRUE(listener->called()); |
| 40 |
| 41 RefPtrWillBeRawPtr<TestListener> listener2 = TestListener::create(); |
| 42 notifier->addListener(listener2); |
| 43 ASSERT_FALSE(listener2->called()); |
| 44 notifier->removeListener(listener2); |
| 45 notifier->viewportChanged(); |
| 46 ASSERT_FALSE(listener2->called()); |
| 47 } |
| 48 |
| 49 } // namespace |
| 50 |
OLD | NEW |