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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/tabs/tab_audio_indicator_unittest.cc
diff --git a/chrome/browser/ui/tabs/tab_audio_indicator_unittest.cc b/chrome/browser/ui/tabs/tab_audio_indicator_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f17c0d7a5eb8a37aeafd9af12e8a62624b3029fa
--- /dev/null
+++ b/chrome/browser/ui/tabs/tab_audio_indicator_unittest.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2013 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 "chrome/browser/ui/tabs/tab_audio_indicator.h"
+
+#include "base/message_loop.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/animation/linear_animation.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/rect.h"
+
+class TabAudioIndicatorTest : public TabAudioIndicator::Delegate,
+ public testing::Test {
+ protected:
+ TabAudioIndicatorTest() : schedule_paint_count_(0) {}
+
+ virtual void ScheduleAudioIndicatorPaint() OVERRIDE {
+ ++schedule_paint_count_;
+ }
+
+ int schedule_paint_count_;
+ MessageLoopForUI message_loop_; // Needed for ui::LinearAnimation.
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TabAudioIndicatorTest);
+};
+
+TEST_F(TabAudioIndicatorTest, AnimationState) {
+ // Start animating.
+ TabAudioIndicator indicator(this);
+ indicator.SetIsPlayingAudio(true);
+ EXPECT_EQ(TabAudioIndicator::STATE_ANIMATING, indicator.state_);
+ EXPECT_TRUE(indicator.IsAnimating());
+
+ // Once the audio stops the indicator should switch to ending animation.
+ indicator.SetIsPlayingAudio(false);
+ EXPECT_EQ(TabAudioIndicator::STATE_ANIMATION_ENDING, indicator.state_);
+ EXPECT_TRUE(indicator.IsAnimating());
+
+ // Once the ending animation is complete animation should stop.
+ indicator.animation_->End();
+ EXPECT_EQ(TabAudioIndicator::STATE_NOT_ANIMATING, indicator.state_);
+ EXPECT_FALSE(indicator.IsAnimating());
+}
+
+TEST_F(TabAudioIndicatorTest, Paint) {
+ TabAudioIndicator indicator(this);
+ indicator.SetIsPlayingAudio(true);
+
+ gfx::Rect rect(0, 0, 16, 16);
+ gfx::Canvas canvas(rect.size(), ui::SCALE_FACTOR_100P, true);
+
+ // Nothing to test here. Just exercise the paint code to verify that nothing
+ // leaks or crashes.
+ indicator.Paint(&canvas, rect);
+}
+
+TEST_F(TabAudioIndicatorTest, SchedulePaint) {
+ TabAudioIndicator indicator(this);
+ indicator.SetIsPlayingAudio(true);
+
+ indicator.animation_->SetCurrentValue(1.0);
+ schedule_paint_count_ = 0;
+ indicator.AnimationProgressed(NULL);
+ EXPECT_EQ(1, schedule_paint_count_);
+}
« 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