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

Side by Side Diff: ash/accelerators/accelerator_controller_unittest.cc

Issue 10825264: Consolidate volume control code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + Fix virutal function name. Created 8 years, 4 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 | « ash/accelerators/accelerator_controller.cc ('k') | ash/system/audio/tray_volume.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/accelerators/accelerator_controller.h" 5 #include "ash/accelerators/accelerator_controller.h"
6 #include "ash/accelerators/accelerator_table.h" 6 #include "ash/accelerators/accelerator_table.h"
7 #include "ash/caps_lock_delegate.h" 7 #include "ash/caps_lock_delegate.h"
8 #include "ash/ime_control_delegate.h" 8 #include "ash/ime_control_delegate.h"
9 #include "ash/screenshot_delegate.h" 9 #include "ash/screenshot_delegate.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/shell_window_ids.h" 11 #include "ash/shell_window_ids.h"
12 #include "ash/system/brightness/brightness_control_delegate.h" 12 #include "ash/system/brightness/brightness_control_delegate.h"
13 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" 13 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h"
14 #include "ash/system/tray/system_tray_delegate.h"
14 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
15 #include "ash/test/test_shell_delegate.h" 16 #include "ash/test/test_shell_delegate.h"
16 #include "ash/volume_control_delegate.h" 17 #include "ash/volume_control_delegate.h"
17 #include "ash/wm/window_util.h" 18 #include "ash/wm/window_util.h"
18 #include "ui/aura/root_window.h" 19 #include "ui/aura/root_window.h"
19 #include "ui/aura/test/test_window_delegate.h" 20 #include "ui/aura/test/test_window_delegate.h"
20 #include "ui/aura/test/test_windows.h" 21 #include "ui/aura/test/test_windows.h"
21 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
22 #include "ui/base/event.h" 23 #include "ui/base/event.h"
23 24
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 last_accelerator_ = accelerator; 137 last_accelerator_ = accelerator;
137 return consume_; 138 return consume_;
138 } 139 }
139 virtual bool HandleVolumeUp(const ui::Accelerator& accelerator) OVERRIDE { 140 virtual bool HandleVolumeUp(const ui::Accelerator& accelerator) OVERRIDE {
140 ++handle_volume_up_count_; 141 ++handle_volume_up_count_;
141 last_accelerator_ = accelerator; 142 last_accelerator_ = accelerator;
142 return consume_; 143 return consume_;
143 } 144 }
144 virtual void SetVolumePercent(double percent) OVERRIDE { 145 virtual void SetVolumePercent(double percent) OVERRIDE {
145 } 146 }
147 virtual bool IsAudioMuted() const OVERRIDE {
148 return false;
149 }
150 virtual void SetAudioMuted(bool muted) OVERRIDE {
151 }
152 virtual float GetVolumeLevel() const OVERRIDE {
153 return 0.0;
154 }
155 virtual void SetVolumeLevel(float level) OVERRIDE {
156 }
146 157
147 int handle_volume_mute_count() const { 158 int handle_volume_mute_count() const {
148 return handle_volume_mute_count_; 159 return handle_volume_mute_count_;
149 } 160 }
150 int handle_volume_down_count() const { 161 int handle_volume_down_count() const {
151 return handle_volume_down_count_; 162 return handle_volume_down_count_;
152 } 163 }
153 int handle_volume_up_count() const { 164 int handle_volume_up_count() const {
154 return handle_volume_up_count_; 165 return handle_volume_up_count_;
155 } 166 }
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 EXPECT_EQ(0, delegate->handle_caps_lock_count()); 619 EXPECT_EQ(0, delegate->handle_caps_lock_count());
609 EXPECT_TRUE(GetController()->Process( 620 EXPECT_TRUE(GetController()->Process(
610 ui::Accelerator(ui::VKEY_LWIN, ui::EF_SHIFT_DOWN))); 621 ui::Accelerator(ui::VKEY_LWIN, ui::EF_SHIFT_DOWN)));
611 EXPECT_EQ(1, delegate->handle_caps_lock_count()); 622 EXPECT_EQ(1, delegate->handle_caps_lock_count());
612 } 623 }
613 // Volume 624 // Volume
614 const ui::Accelerator f8(ui::VKEY_F8, ui::EF_NONE); 625 const ui::Accelerator f8(ui::VKEY_F8, ui::EF_NONE);
615 const ui::Accelerator f9(ui::VKEY_F9, ui::EF_NONE); 626 const ui::Accelerator f9(ui::VKEY_F9, ui::EF_NONE);
616 const ui::Accelerator f10(ui::VKEY_F10, ui::EF_NONE); 627 const ui::Accelerator f10(ui::VKEY_F10, ui::EF_NONE);
617 { 628 {
618 EXPECT_FALSE(GetController()->Process(f8)); 629 EXPECT_TRUE(GetController()->Process(f8));
619 EXPECT_FALSE(GetController()->Process(f9)); 630 EXPECT_TRUE(GetController()->Process(f9));
620 EXPECT_FALSE(GetController()->Process(f10)); 631 EXPECT_TRUE(GetController()->Process(f10));
621 DummyVolumeControlDelegate* delegate = 632 DummyVolumeControlDelegate* delegate =
622 new DummyVolumeControlDelegate(false); 633 new DummyVolumeControlDelegate(false);
623 GetController()->SetVolumeControlDelegate( 634 ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate(
624 scoped_ptr<VolumeControlDelegate>(delegate).Pass()); 635 scoped_ptr<VolumeControlDelegate>(delegate).Pass());
625 EXPECT_EQ(0, delegate->handle_volume_mute_count()); 636 EXPECT_EQ(0, delegate->handle_volume_mute_count());
626 EXPECT_FALSE(GetController()->Process(f8)); 637 EXPECT_FALSE(GetController()->Process(f8));
627 EXPECT_EQ(1, delegate->handle_volume_mute_count()); 638 EXPECT_EQ(1, delegate->handle_volume_mute_count());
628 EXPECT_EQ(f8, delegate->last_accelerator()); 639 EXPECT_EQ(f8, delegate->last_accelerator());
629 EXPECT_EQ(0, delegate->handle_volume_down_count()); 640 EXPECT_EQ(0, delegate->handle_volume_down_count());
630 EXPECT_FALSE(GetController()->Process(f9)); 641 EXPECT_FALSE(GetController()->Process(f9));
631 EXPECT_EQ(1, delegate->handle_volume_down_count()); 642 EXPECT_EQ(1, delegate->handle_volume_down_count());
632 EXPECT_EQ(f9, delegate->last_accelerator()); 643 EXPECT_EQ(f9, delegate->last_accelerator());
633 EXPECT_EQ(0, delegate->handle_volume_up_count()); 644 EXPECT_EQ(0, delegate->handle_volume_up_count());
634 EXPECT_FALSE(GetController()->Process(f10)); 645 EXPECT_FALSE(GetController()->Process(f10));
635 EXPECT_EQ(1, delegate->handle_volume_up_count()); 646 EXPECT_EQ(1, delegate->handle_volume_up_count());
636 EXPECT_EQ(f10, delegate->last_accelerator()); 647 EXPECT_EQ(f10, delegate->last_accelerator());
637 } 648 }
638 { 649 {
639 DummyVolumeControlDelegate* delegate = new DummyVolumeControlDelegate(true); 650 DummyVolumeControlDelegate* delegate = new DummyVolumeControlDelegate(true);
640 GetController()->SetVolumeControlDelegate( 651 ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate(
641 scoped_ptr<VolumeControlDelegate>(delegate).Pass()); 652 scoped_ptr<VolumeControlDelegate>(delegate).Pass());
642 EXPECT_EQ(0, delegate->handle_volume_mute_count()); 653 EXPECT_EQ(0, delegate->handle_volume_mute_count());
643 EXPECT_TRUE(GetController()->Process(f8)); 654 EXPECT_TRUE(GetController()->Process(f8));
644 EXPECT_EQ(1, delegate->handle_volume_mute_count()); 655 EXPECT_EQ(1, delegate->handle_volume_mute_count());
645 EXPECT_EQ(f8, delegate->last_accelerator()); 656 EXPECT_EQ(f8, delegate->last_accelerator());
646 EXPECT_EQ(0, delegate->handle_volume_down_count()); 657 EXPECT_EQ(0, delegate->handle_volume_down_count());
647 EXPECT_TRUE(GetController()->Process(f9)); 658 EXPECT_TRUE(GetController()->Process(f9));
648 EXPECT_EQ(1, delegate->handle_volume_down_count()); 659 EXPECT_EQ(1, delegate->handle_volume_down_count());
649 EXPECT_EQ(f9, delegate->last_accelerator()); 660 EXPECT_EQ(f9, delegate->last_accelerator());
650 EXPECT_EQ(0, delegate->handle_volume_up_count()); 661 EXPECT_EQ(0, delegate->handle_volume_up_count());
651 EXPECT_TRUE(GetController()->Process(f10)); 662 EXPECT_TRUE(GetController()->Process(f10));
652 EXPECT_EQ(1, delegate->handle_volume_up_count()); 663 EXPECT_EQ(1, delegate->handle_volume_up_count());
653 EXPECT_EQ(f10, delegate->last_accelerator()); 664 EXPECT_EQ(f10, delegate->last_accelerator());
654 } 665 }
655 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE); 666 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE);
656 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); 667 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
657 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE); 668 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE);
658 { 669 {
659 DummyVolumeControlDelegate* delegate = 670 DummyVolumeControlDelegate* delegate =
660 new DummyVolumeControlDelegate(false); 671 new DummyVolumeControlDelegate(false);
661 GetController()->SetVolumeControlDelegate( 672 ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate(
662 scoped_ptr<VolumeControlDelegate>(delegate).Pass()); 673 scoped_ptr<VolumeControlDelegate>(delegate).Pass());
663 EXPECT_EQ(0, delegate->handle_volume_mute_count()); 674 EXPECT_EQ(0, delegate->handle_volume_mute_count());
664 EXPECT_FALSE(GetController()->Process(volume_mute)); 675 EXPECT_FALSE(GetController()->Process(volume_mute));
665 EXPECT_EQ(1, delegate->handle_volume_mute_count()); 676 EXPECT_EQ(1, delegate->handle_volume_mute_count());
666 EXPECT_EQ(volume_mute, delegate->last_accelerator()); 677 EXPECT_EQ(volume_mute, delegate->last_accelerator());
667 EXPECT_EQ(0, delegate->handle_volume_down_count()); 678 EXPECT_EQ(0, delegate->handle_volume_down_count());
668 EXPECT_FALSE(GetController()->Process(volume_down)); 679 EXPECT_FALSE(GetController()->Process(volume_down));
669 EXPECT_EQ(1, delegate->handle_volume_down_count()); 680 EXPECT_EQ(1, delegate->handle_volume_down_count());
670 EXPECT_EQ(volume_down, delegate->last_accelerator()); 681 EXPECT_EQ(volume_down, delegate->last_accelerator());
671 EXPECT_EQ(0, delegate->handle_volume_up_count()); 682 EXPECT_EQ(0, delegate->handle_volume_up_count());
672 EXPECT_FALSE(GetController()->Process(volume_up)); 683 EXPECT_FALSE(GetController()->Process(volume_up));
673 EXPECT_EQ(1, delegate->handle_volume_up_count()); 684 EXPECT_EQ(1, delegate->handle_volume_up_count());
674 EXPECT_EQ(volume_up, delegate->last_accelerator()); 685 EXPECT_EQ(volume_up, delegate->last_accelerator());
675 } 686 }
676 { 687 {
677 DummyVolumeControlDelegate* delegate = new DummyVolumeControlDelegate(true); 688 DummyVolumeControlDelegate* delegate = new DummyVolumeControlDelegate(true);
678 GetController()->SetVolumeControlDelegate( 689 ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate(
679 scoped_ptr<VolumeControlDelegate>(delegate).Pass()); 690 scoped_ptr<VolumeControlDelegate>(delegate).Pass());
680 EXPECT_EQ(0, delegate->handle_volume_mute_count()); 691 EXPECT_EQ(0, delegate->handle_volume_mute_count());
681 EXPECT_TRUE(GetController()->Process(volume_mute)); 692 EXPECT_TRUE(GetController()->Process(volume_mute));
682 EXPECT_EQ(1, delegate->handle_volume_mute_count()); 693 EXPECT_EQ(1, delegate->handle_volume_mute_count());
683 EXPECT_EQ(volume_mute, delegate->last_accelerator()); 694 EXPECT_EQ(volume_mute, delegate->last_accelerator());
684 EXPECT_EQ(0, delegate->handle_volume_down_count()); 695 EXPECT_EQ(0, delegate->handle_volume_down_count());
685 EXPECT_TRUE(GetController()->Process(volume_down)); 696 EXPECT_TRUE(GetController()->Process(volume_down));
686 EXPECT_EQ(1, delegate->handle_volume_down_count()); 697 EXPECT_EQ(1, delegate->handle_volume_down_count());
687 EXPECT_EQ(volume_down, delegate->last_accelerator()); 698 EXPECT_EQ(volume_down, delegate->last_accelerator());
688 EXPECT_EQ(0, delegate->handle_volume_up_count()); 699 EXPECT_EQ(0, delegate->handle_volume_up_count());
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 EXPECT_FALSE(GetController()->IsReservedAccelerator( 989 EXPECT_FALSE(GetController()->IsReservedAccelerator(
979 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); 990 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE)));
980 EXPECT_FALSE(GetController()->IsReservedAccelerator( 991 EXPECT_FALSE(GetController()->IsReservedAccelerator(
981 ui::Accelerator(ui::VKEY_TAB, ui::EF_NONE))); 992 ui::Accelerator(ui::VKEY_TAB, ui::EF_NONE)));
982 EXPECT_FALSE(GetController()->IsReservedAccelerator( 993 EXPECT_FALSE(GetController()->IsReservedAccelerator(
983 ui::Accelerator(ui::VKEY_A, ui::EF_NONE))); 994 ui::Accelerator(ui::VKEY_A, ui::EF_NONE)));
984 } 995 }
985 996
986 } // namespace test 997 } // namespace test
987 } // namespace ash 998 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller.cc ('k') | ash/system/audio/tray_volume.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698