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

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: rebase 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
« no previous file with comments | « chrome/browser/ui/tabs/tab_audio_indicator.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
54 // Nothing to test here. Just exercise the paint code to verify that nothing
55 // leaks or crashes.
56 indicator.Paint(&canvas, rect);
57 }
58
59 TEST_F(TabAudioIndicatorTest, SchedulePaint) {
60 TabAudioIndicator indicator(this);
61 indicator.SetIsPlayingAudio(true);
62
63 indicator.animation_->SetCurrentValue(1.0);
64 schedule_paint_count_ = 0;
65 indicator.AnimationProgressed(NULL);
66 EXPECT_EQ(1, schedule_paint_count_);
67 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tabs/tab_audio_indicator.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698