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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutProgressTest.cpp

Issue 1721943002: Don't animate a progress bar if it isn't animated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutProgress.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutProgressTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutProgressTest.cpp b/third_party/WebKit/Source/core/layout/LayoutProgressTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eaf410f3895e1226b744cd5fbbbd55c95c5b574a
--- /dev/null
+++ b/third_party/WebKit/Source/core/layout/LayoutProgressTest.cpp
@@ -0,0 +1,46 @@
+// Copyright 2016 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 "core/layout/LayoutProgress.h"
+
+#include "core/HTMLNames.h"
+#include "core/html/HTMLElement.h"
+#include "core/layout/LayoutTestHelper.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+class LayoutProgressTest : public RenderingTest {
+public:
+ static bool isAnimationTimerActive(const LayoutProgress* o) { return o->isAnimationTimerActive(); }
+ static bool isAnimatiing(const LayoutProgress* o) { return o->isAnimating(); }
+};
+
+TEST_F(LayoutProgressTest, AnimationScheduling)
+{
+ RenderingTest::setBodyInnerHTML("<progress id=\"progressElement\" value=0.3 max=1.0></progress>");
+ document().view()->updateAllLifecyclePhases();
+ Element* progressElement = document().getElementById(AtomicString("progressElement"));
+ LayoutProgress* layoutProgress = toLayoutProgress(progressElement->layoutObject());
+
+ // Verify that we do not schedule a timer for a determinant progress element
+ EXPECT_FALSE(LayoutProgressTest::isAnimationTimerActive(layoutProgress));
+ EXPECT_FALSE(LayoutProgressTest::isAnimatiing(layoutProgress));
+
+ progressElement->removeAttribute("value");
+ document().view()->updateAllLifecyclePhases();
+
+ // Verify that we schedule a timer for an indeterminant progress element
+ EXPECT_TRUE(LayoutProgressTest::isAnimationTimerActive(layoutProgress));
+ EXPECT_TRUE(LayoutProgressTest::isAnimatiing(layoutProgress));
+
+ progressElement->setAttribute(HTMLNames::valueAttr, "0.7");
+ document().view()->updateAllLifecyclePhases();
+
+ // Verify that we cancel the timer for a determinant progress element
+ EXPECT_FALSE(LayoutProgressTest::isAnimationTimerActive(layoutProgress));
+ EXPECT_FALSE(LayoutProgressTest::isAnimatiing(layoutProgress));
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutProgress.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698