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

Side by Side Diff: chrome/browser/chromeos/setting_level_bubble_browsertest.cc

Issue 8319008: aura: brightness and volume bubble. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: styles Created 9 years, 1 month 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) 2011 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 "base/message_loop.h"
6 #include "chrome/browser/chromeos/setting_level_bubble.h"
7 #include "chrome/browser/chromeos/setting_level_bubble_view.h"
8 #include "chrome/test/base/in_process_browser_test.h"
9 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "views/controls/progress_bar.h"
11 #include "views/view.h"
12
13
14 typedef InProcessBrowserTest SettingLevelBubbleTest;
15
16 namespace chromeos {
17
18 IN_PROC_BROWSER_TEST_F(SettingLevelBubbleTest, CreateAndUpdate) {
19 SkBitmap up_icon;
20 up_icon.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
21 SkBitmap down_icon;
22 down_icon.setConfig(SkBitmap::kARGB_8888_Config, 5, 5);
23 SkBitmap mute_icon;
24 mute_icon.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
25 SettingLevelBubble bubble(&up_icon,
26 &down_icon,
27 &mute_icon);
28 EXPECT_FALSE(bubble.view_ != NULL);
29 EXPECT_EQ(&up_icon, bubble.increase_icon_);
30 EXPECT_EQ(&down_icon, bubble.decrease_icon_);
31 EXPECT_EQ(&mute_icon, bubble.disabled_icon_);
32
33 // Update setting:
34 // Old target is 50, new target is 70, set enable = false.
35 bubble.ShowBubble(70, false);
36 EXPECT_TRUE(bubble.view_->GetWidget()->IsVisible());
37 EXPECT_EQ(&mute_icon, bubble.view_->icon_);
38 EXPECT_FALSE(bubble.view_->progress_bar_->IsEnabled());
39
40 // Old target is 70, new target is 30, set enable = true.
41 bubble.ShowBubble(30, true);
42 EXPECT_EQ(&down_icon, bubble.view_->icon_);
43 EXPECT_TRUE(bubble.view_->progress_bar_->IsEnabled());
44
45 // Old target is 30, new target is 0, set enable = true.
46 bubble.ShowBubble(0, true);
47 EXPECT_EQ(&mute_icon, bubble.view_->icon_);
48 EXPECT_TRUE(bubble.view_->progress_bar_->IsEnabled());
49
50 MessageLoop::current()->RunAllPending();
51 }
52
53 IN_PROC_BROWSER_TEST_F(SettingLevelBubbleTest, ShowBubble) {
54 SkBitmap* dummy_icon = new SkBitmap;
55 dummy_icon->setConfig(SkBitmap::kARGB_8888_Config, 50, 50);
56 // Create setting at 30 percent, enabled.
57 SettingLevelBubble bubble(dummy_icon, dummy_icon, dummy_icon);
58 bubble.UpdateWithoutShowingBubble(30, false);
59 EXPECT_FALSE(bubble.view_ != NULL);
60 EXPECT_EQ(30, bubble.current_percent_);
61
62 // Show bubble at 40 percent, enabled.
63 bubble.ShowBubble(40, true);
64 EXPECT_TRUE(bubble.view_ != NULL);
65 EXPECT_TRUE(bubble.view_->GetWidget()->IsVisible());
66
67 // Update to 0 percent and close.
68 bubble.UpdateWithoutShowingBubble(0, true);
69 bubble.OnWidgetClosing(bubble.view_->GetWidget());
70 EXPECT_EQ(0, bubble.current_percent_);
71 }
72
73 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698