Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Unified Diff: Source/core/html/StableStateTest.cpp

Issue 153813002: Support "await a stable state" and "provide a stable state" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/StableStateTest.cpp
diff --git a/Source/core/html/StableStateTest.cpp b/Source/core/html/StableStateTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6059d8bb803331d9a8deaa22826ea7c3f9cdd5b0
--- /dev/null
+++ b/Source/core/html/StableStateTest.cpp
@@ -0,0 +1,100 @@
+// 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/html/StableState.h"
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+using WebCore::StableState;
+
+namespace {
+
+class MockAwaiter : public StableState::Awaiter {
+public:
+ MOCK_METHOD0(didAwaitStableState, void());
+};
+
+TEST(StableState, Await)
+{
+ MockAwaiter awaiter;
+ EXPECT_CALL(awaiter, didAwaitStableState()).Times(0);
+ awaiter.awaitStableState();
+}
+
+TEST(StableState, AwaitProvide)
+{
+ MockAwaiter awaiter;
+ EXPECT_CALL(awaiter, didAwaitStableState()).Times(1);
+ awaiter.awaitStableState();
+ StableState::provide();
+}
+
+TEST(StableState, AwaitProvideTwice)
+{
+ MockAwaiter awaiter;
+ EXPECT_CALL(awaiter, didAwaitStableState()).Times(1);
+ awaiter.awaitStableState();
+ StableState::provide();
+ StableState::provide();
+}
+
+TEST(StableState, AwaitTwiceProvide)
+{
+ MockAwaiter awaiter;
+ EXPECT_CALL(awaiter, didAwaitStableState()).Times(1);
+ awaiter.awaitStableState();
+ awaiter.awaitStableState();
+ StableState::provide();
+}
+
+TEST(StableState, AwaitProvideAwaitProvide)
+{
+ MockAwaiter awaiter;
+ EXPECT_CALL(awaiter, didAwaitStableState()).Times(2);
+ awaiter.awaitStableState();
+ StableState::provide();
+ awaiter.awaitStableState();
+ StableState::provide();
+}
+
+TEST(StableState, StopProvide)
+{
+ MockAwaiter awaiter;
+ EXPECT_CALL(awaiter, didAwaitStableState()).Times(0);
+ awaiter.stopAwaitingStableState();
+ StableState::provide();
+}
+
+TEST(StableState, StopAwaitProvide)
+{
+ MockAwaiter awaiter;
+ EXPECT_CALL(awaiter, didAwaitStableState()).Times(1);
+ awaiter.stopAwaitingStableState();
+ awaiter.awaitStableState();
+ StableState::provide();
+}
+
+TEST(StableState, AwaitStopProvide)
+{
+ MockAwaiter awaiter;
+ EXPECT_CALL(awaiter, didAwaitStableState()).Times(0);
+ awaiter.awaitStableState();
+ awaiter.stopAwaitingStableState();
+ StableState::provide();
+}
+
+TEST(StableState, TwoAwaiters)
+{
+ MockAwaiter awaiter1;
+ MockAwaiter awaiter2;
+ EXPECT_CALL(awaiter1, didAwaitStableState()).Times(1);
+ EXPECT_CALL(awaiter2, didAwaitStableState()).Times(1);
+ awaiter1.awaitStableState();
+ awaiter2.awaitStableState();
+ StableState::provide();
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698