summaryrefslogtreecommitdiffstats
path: root/ui/views/animation/ink_drop_hover_unittest.cc
blob: 5657569ad2353668b818db36d427ed17f749c091 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2015 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 "ui/views/animation/ink_drop_hover.h"

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/gfx/geometry/size.h"

namespace views {
namespace test {

class InkDropHoverTest : public testing::Test {
 public:
  InkDropHoverTest();
  ~InkDropHoverTest() override;

 protected:
  scoped_ptr<InkDropHover> CreateInkDropHover() const;

 private:
  // Enables zero duration animations during the tests.
  scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;

  DISALLOW_COPY_AND_ASSIGN(InkDropHoverTest);
};

InkDropHoverTest::InkDropHoverTest() {
  zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
      ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
}

InkDropHoverTest::~InkDropHoverTest() {}

scoped_ptr<InkDropHover> InkDropHoverTest::CreateInkDropHover() const {
  return make_scoped_ptr(
      new InkDropHover(gfx::Size(10, 10), 3, gfx::Point(), SK_ColorBLACK));
}

TEST_F(InkDropHoverTest, InitialStateAfterConstruction) {
  scoped_ptr<InkDropHover> ink_drop_hover = CreateInkDropHover();
  EXPECT_FALSE(ink_drop_hover->IsFadingInOrVisible());
}

TEST_F(InkDropHoverTest, IsHoveredStateTransitions) {
  scoped_ptr<InkDropHover> ink_drop_hover = CreateInkDropHover();

  ink_drop_hover->FadeIn(base::TimeDelta::FromMilliseconds(0));
  EXPECT_TRUE(ink_drop_hover->IsFadingInOrVisible());

  ink_drop_hover->FadeOut(base::TimeDelta::FromMilliseconds(0));
  EXPECT_FALSE(ink_drop_hover->IsFadingInOrVisible());
}

}  // namespace test
}  // namespace views