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

Side by Side Diff: chrome/browser/ui/tabs/tab_audio_indicator_unittest.cc

Issue 12744003: Audio indicator: cross platform drawing and animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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 "chrome/browser/ui/tabs/tab_audio_indicator.h"
6
7 #include "base/message_loop.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/base/animation/linear_animation.h"
10 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/rect.h"
12
13 class TabAudioIndicatorTest : public TabAudioIndicator::Delegate,
14 public testing::Test {
15 protected:
16 TabAudioIndicatorTest() : schedule_paint_count_(0) {}
17
18 virtual void ScheduleAudioIndicatorPaint() OVERRIDE {
19 ++schedule_paint_count_;
20 }
21
22 int schedule_paint_count_;
23 MessageLoopForUI message_loop_; // Needed for ui::LinearAnimation.
24
25 private:
26 DISALLOW_COPY_AND_ASSIGN(TabAudioIndicatorTest);
27 };
28
29 TEST_F(TabAudioIndicatorTest, AnimationState) {
30 // Start animating.
31 TabAudioIndicator indicator(this);
32 indicator.SetIsPlayingAudio(true);
33 EXPECT_EQ(TabAudioIndicator::STATE_ANIMATING, indicator.state_);
34 EXPECT_TRUE(indicator.IsAnimating());
35
36 // Once the audio stops the indicator should switch to ending animation.
37 indicator.SetIsPlayingAudio(false);
38 EXPECT_EQ(TabAudioIndicator::STATE_ANIMATION_ENDING, indicator.state_);
39 EXPECT_TRUE(indicator.IsAnimating());
40
41 // Once the ending animation is complete animation should stop.
42 indicator.animation_->End();
43 EXPECT_EQ(TabAudioIndicator::STATE_NOT_ANIMATING, indicator.state_);
44 EXPECT_FALSE(indicator.IsAnimating());
45 }
46
47 TEST_F(TabAudioIndicatorTest, Paint) {
48 TabAudioIndicator indicator(this);
49 indicator.SetIsPlayingAudio(true);
50
51 gfx::Rect rect(0, 0, 16, 16);
52 gfx::Canvas canvas(rect.size(), ui::SCALE_FACTOR_100P, true);
53 indicator.Paint(&canvas, rect);
cpu_(ooo_6.6-7.5) 2013/03/11 02:40:27 what are we testing here?
sail 2013/03/11 23:16:13 Just exercising the code to make sure nothing leak
54 }
55
56 TEST_F(TabAudioIndicatorTest, SchedulePaint) {
57 TabAudioIndicator indicator(this);
58 indicator.SetIsPlayingAudio(true);
59
60 indicator.animation_->SetCurrentValue(1.0);
61 schedule_paint_count_ = 0;
62 indicator.AnimationProgressed(NULL);
63 EXPECT_EQ(1, schedule_paint_count_);
64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698