Index: Source/core/frame/ViewportChangeNotifierTest.cpp |
diff --git a/Source/core/frame/ViewportChangeNotifierTest.cpp b/Source/core/frame/ViewportChangeNotifierTest.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1ea62fddeb98f7a842853570e541a1f5f56fb435 |
--- /dev/null |
+++ b/Source/core/frame/ViewportChangeNotifierTest.cpp |
@@ -0,0 +1,50 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "core/frame/ViewportChangeNotifier.h" |
+ |
+#include <gtest/gtest.h> |
+ |
+namespace WebCore { |
+ |
+class TestListener: public ViewportChangeListener { |
+public: |
+ static PassRefPtrWillBeRawPtr<TestListener> create() { return adoptRefWillBeNoop(new TestListener()); } |
+ |
+ void viewportChanged() |
+ { |
+ m_listenerCalled = true; |
+ } |
+ |
+ TestListener() |
+ : m_listenerCalled(false) |
+ { |
+ } |
+ |
+ bool called() const { return m_listenerCalled; } |
+ |
+private: |
+ bool m_listenerCalled; |
+}; |
+ |
+TEST(ViewportChangeNotifierTest, Basic) |
+{ |
+ OwnPtrWillBeRawPtr<ViewportChangeNotifier> notifier = ViewportChangeNotifier::create(); |
+ RefPtrWillBeRawPtr<TestListener> listener = TestListener::create(); |
+ notifier->addListener(listener.get()); |
+ ASSERT_FALSE(listener->called()); |
+ notifier->viewportChanged(); |
+ ASSERT_TRUE(listener->called()); |
+ |
+ RefPtrWillBeRawPtr<TestListener> listener2 = TestListener::create(); |
+ notifier->addListener(listener2.get()); |
+ ASSERT_FALSE(listener2->called()); |
+ notifier->removeListener(listener2.get()); |
+ notifier->viewportChanged(); |
+ ASSERT_FALSE(listener2->called()); |
+} |
+ |
+} // namespace |
+ |