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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 "core/layout/LayoutProgress.h"
6
7 #include "core/HTMLNames.h"
8 #include "core/html/HTMLElement.h"
9 #include "core/layout/LayoutTestHelper.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace blink {
13
14 class LayoutProgressTest : public RenderingTest {
15 public:
16 static bool isAnimationTimerActive(const LayoutProgress* o) { return o->isAn imationTimerActive(); }
17 };
18
19 TEST_F(LayoutProgressTest, AnimationScheduling)
20 {
21 document().documentElement()->setInnerHTML(
22 String::fromUTF8("<progress id=\"progressElement\" value=0.3 max=1.0></p rogress>"), ASSERT_NO_EXCEPTION);
23 document().view()->updateAllLifecyclePhases();
Xianzhu 2016/02/22 23:17:27 Nits: - You can use RenderingTest::setBodyInnerHTM
Stephen Chennney 2016/02/23 19:24:01 Acknowledged.
24 Element* progressElement = document().getElementById(AtomicString("progressE lement"));
25 LayoutProgress* layoutProgress = toLayoutProgress(progressElement->layoutObj ect());
26
27 // Verify that we do not schedule a timer for a determinant progress element
28 EXPECT_FALSE(LayoutProgressTest::isAnimationTimerActive(layoutProgress));
29
30 progressElement->removeAttribute("value");
31 document().view()->updateAllLifecyclePhases();
32
33 // Verify that we schedule a timer for an indeterminant progress element
34 EXPECT_TRUE(LayoutProgressTest::isAnimationTimerActive(layoutProgress));
35
36 progressElement->setAttribute(HTMLNames::valueAttr, "0.7");
37 document().view()->updateAllLifecyclePhases();
38
39 // Verify that we cancel the timer for a determinant progress element
40 EXPECT_FALSE(LayoutProgressTest::isAnimationTimerActive(layoutProgress));
41 }
42
43 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698