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

Side by Side Diff: chrome/browser/ui/toolbar/app_menu_icon_painter_unittest.cc

Issue 2374803002: Remove a bunch of pre-MD toolbar code and assets. (Closed)
Patch Set: fix mac? Created 4 years, 2 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
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/toolbar/app_menu_icon_painter.h"
6
7 #include "base/macros.h"
8 #include "chrome/browser/themes/theme_service.h"
9 #include "chrome/browser/themes/theme_service_factory.h"
10 #include "chrome/grit/theme_resources.h"
11 #include "chrome/test/base/testing_profile.h"
12 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/gfx/canvas.h"
15 #include "ui/gfx/geometry/rect.h"
16
17 class AppMenuIconPainterTest : public testing::Test,
18 public AppMenuIconPainter::Delegate {
19 public:
20 AppMenuIconPainterTest()
21 : schedule_paint_count_(0),
22 theme_provider_(ThemeService::GetThemeProviderForProfile(&profile_)),
23 painter_(this) {}
24
25 void ScheduleAppMenuIconPaint() override { ++schedule_paint_count_; }
26
27 protected:
28 // Needed for gfx::Animation and the testing profile.
29 content::TestBrowserThreadBundle thread_bundle_;
30 TestingProfile profile_;
31 int schedule_paint_count_;
32 const ui::ThemeProvider& theme_provider_;
33 AppMenuIconPainter painter_;
34
35 private:
36 DISALLOW_COPY_AND_ASSIGN(AppMenuIconPainterTest);
37 };
38
39 // Nothing to test here. Just exercise the paint code to verify that nothing
40 // leaks or crashes.
41 TEST_F(AppMenuIconPainterTest, Paint) {
42 gfx::Rect rect(0, 0, 29, 29);
43 gfx::Canvas canvas(rect.size(), 1.0f, true);
44
45 painter_.Paint(&canvas, &theme_provider_, rect,
46 AppMenuIconPainter::BEZEL_NONE);
47 painter_.Paint(&canvas, &theme_provider_, rect,
48 AppMenuIconPainter::BEZEL_HOVER);
49 painter_.Paint(&canvas, &theme_provider_, rect,
50 AppMenuIconPainter::BEZEL_PRESSED);
51
52 painter_.SetSeverity(AppMenuIconPainter::SEVERITY_LOW, true);
53 painter_.Paint(&canvas, &theme_provider_, rect,
54 AppMenuIconPainter::BEZEL_PRESSED);
55 painter_.SetSeverity(AppMenuIconPainter::SEVERITY_MEDIUM, true);
56 painter_.Paint(&canvas, &theme_provider_, rect,
57 AppMenuIconPainter::BEZEL_PRESSED);
58 painter_.SetSeverity(AppMenuIconPainter::SEVERITY_HIGH, true);
59 painter_.Paint(&canvas, &theme_provider_, rect,
60 AppMenuIconPainter::BEZEL_PRESSED);
61
62 painter_.set_badge(*theme_provider_.GetImageSkiaNamed(IDR_PRODUCT_LOGO_16));
63 painter_.Paint(&canvas, &theme_provider_, rect,
64 AppMenuIconPainter::BEZEL_PRESSED);
65 }
66
67 TEST_F(AppMenuIconPainterTest, PaintCallback) {
68 painter_.SetSeverity(AppMenuIconPainter::SEVERITY_LOW, true);
69 schedule_paint_count_ = 0;
70 painter_.AnimationProgressed(NULL);
71 EXPECT_EQ(1, schedule_paint_count_);
72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698