| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/tabs/tab_audio_indicator.h" | 5 #include "chrome/browser/ui/tabs/tab_audio_indicator.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "grit/theme_resources.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/base/animation/linear_animation.h" | 10 #include "ui/base/animation/linear_animation.h" |
| 11 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
| 11 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
| 12 | 14 |
| 13 class TabAudioIndicatorTest : public TabAudioIndicator::Delegate, | 15 class TabAudioIndicatorTest : public TabAudioIndicator::Delegate, |
| 14 public testing::Test { | 16 public testing::Test { |
| 15 protected: | 17 protected: |
| 16 TabAudioIndicatorTest() : schedule_paint_count_(0) {} | 18 TabAudioIndicatorTest() : schedule_paint_count_(0) {} |
| 17 | 19 |
| 18 virtual void ScheduleAudioIndicatorPaint() OVERRIDE { | 20 virtual void ScheduleAudioIndicatorPaint() OVERRIDE { |
| 19 ++schedule_paint_count_; | 21 ++schedule_paint_count_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 47 TEST_F(TabAudioIndicatorTest, Paint) { | 49 TEST_F(TabAudioIndicatorTest, Paint) { |
| 48 TabAudioIndicator indicator(this); | 50 TabAudioIndicator indicator(this); |
| 49 indicator.SetIsPlayingAudio(true); | 51 indicator.SetIsPlayingAudio(true); |
| 50 | 52 |
| 51 gfx::Rect rect(0, 0, 16, 16); | 53 gfx::Rect rect(0, 0, 16, 16); |
| 52 gfx::Canvas canvas(rect.size(), ui::SCALE_FACTOR_100P, true); | 54 gfx::Canvas canvas(rect.size(), ui::SCALE_FACTOR_100P, true); |
| 53 | 55 |
| 54 // Nothing to test here. Just exercise the paint code to verify that nothing | 56 // Nothing to test here. Just exercise the paint code to verify that nothing |
| 55 // leaks or crashes. | 57 // leaks or crashes. |
| 56 indicator.Paint(&canvas, rect); | 58 indicator.Paint(&canvas, rect); |
| 59 |
| 60 // Paint with a favicon. |
| 61 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 62 indicator.set_favicon(*rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_16)); |
| 63 indicator.Paint(&canvas, rect); |
| 57 } | 64 } |
| 58 | 65 |
| 59 TEST_F(TabAudioIndicatorTest, SchedulePaint) { | 66 TEST_F(TabAudioIndicatorTest, SchedulePaint) { |
| 60 TabAudioIndicator indicator(this); | 67 TabAudioIndicator indicator(this); |
| 61 indicator.SetIsPlayingAudio(true); | 68 indicator.SetIsPlayingAudio(true); |
| 62 | 69 |
| 63 indicator.animation_->SetCurrentValue(1.0); | 70 indicator.animation_->SetCurrentValue(1.0); |
| 64 schedule_paint_count_ = 0; | 71 schedule_paint_count_ = 0; |
| 65 indicator.AnimationProgressed(NULL); | 72 indicator.AnimationProgressed(NULL); |
| 66 EXPECT_EQ(1, schedule_paint_count_); | 73 EXPECT_EQ(1, schedule_paint_count_); |
| 67 } | 74 } |
| OLD | NEW |