| 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..d285e4e63b0ba450ef3acb087e3cbbde382987ef
|
| --- /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);
|
| + ASSERT_FALSE(listener->called());
|
| + notifier->viewportChanged();
|
| + ASSERT_TRUE(listener->called());
|
| +
|
| + RefPtrWillBeRawPtr<TestListener> listener2 = TestListener::create();
|
| + notifier->addListener(listener2);
|
| + ASSERT_FALSE(listener2->called());
|
| + notifier->removeListener(listener2);
|
| + notifier->viewportChanged();
|
| + ASSERT_FALSE(listener2->called());
|
| +}
|
| +
|
| +} // namespace
|
| +
|
|
|