OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/status_icons/status_icon_menu_model.h" | 5 #include "chrome/browser/status_icons/status_icon_menu_model.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/status_icons/status_icon.h" | 10 #include "chrome/browser/status_icons/status_icon.h" |
11 #include "chrome/browser/status_icons/status_tray.h" | 11 #include "chrome/browser/status_icons/status_tray.h" |
12 #include "grit/chrome_unscaled_resources.h" | 12 #include "grit/chrome_unscaled_resources.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "ui/base/accelerators/accelerator.h" | 14 #include "ui/base/accelerators/accelerator.h" |
15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
16 #include "ui/gfx/image/image.h" | 16 #include "ui/gfx/image/image.h" |
17 | 17 |
18 using base::ASCIIToUTF16; | 18 using base::ASCIIToUTF16; |
19 | 19 |
20 class StatusIconMenuModelTest : public testing::Test, | 20 class StatusIconMenuModelTest : public testing::Test, |
21 public StatusIconMenuModel::Observer { | 21 public StatusIconMenuModel::Observer { |
22 public: | 22 public: |
23 virtual void SetUp() OVERRIDE { | 23 virtual void SetUp() override { |
24 menu_.reset(new StatusIconMenuModel(NULL)); | 24 menu_.reset(new StatusIconMenuModel(NULL)); |
25 menu_->AddObserver(this); | 25 menu_->AddObserver(this); |
26 changed_count_ = 0; | 26 changed_count_ = 0; |
27 } | 27 } |
28 | 28 |
29 virtual void TearDown() OVERRIDE { | 29 virtual void TearDown() override { |
30 menu_->RemoveObserver(this); | 30 menu_->RemoveObserver(this); |
31 } | 31 } |
32 | 32 |
33 virtual int changed_count() { | 33 virtual int changed_count() { |
34 return changed_count_; | 34 return changed_count_; |
35 } | 35 } |
36 | 36 |
37 StatusIconMenuModel* menu_model() { | 37 StatusIconMenuModel* menu_model() { |
38 return menu_.get(); | 38 return menu_.get(); |
39 } | 39 } |
40 | 40 |
41 private: | 41 private: |
42 virtual void OnMenuStateChanged() OVERRIDE { | 42 virtual void OnMenuStateChanged() override { |
43 ++changed_count_; | 43 ++changed_count_; |
44 } | 44 } |
45 | 45 |
46 scoped_ptr<StatusIconMenuModel> menu_; | 46 scoped_ptr<StatusIconMenuModel> menu_; |
47 int changed_count_; | 47 int changed_count_; |
48 }; | 48 }; |
49 | 49 |
50 TEST_F(StatusIconMenuModelTest, ToggleBooleanProperties) { | 50 TEST_F(StatusIconMenuModelTest, ToggleBooleanProperties) { |
51 menu_model()->AddItem(0, ASCIIToUTF16("foo")); | 51 menu_model()->AddItem(0, ASCIIToUTF16("foo")); |
52 | 52 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 // Ensure changes to one menu item does not affect the other menu item. | 108 // Ensure changes to one menu item does not affect the other menu item. |
109 EXPECT_FALSE(menu_model()->GetAcceleratorForCommandId(1, &accel_arg)); | 109 EXPECT_FALSE(menu_model()->GetAcceleratorForCommandId(1, &accel_arg)); |
110 EXPECT_EQ(base::string16(), menu_model()->GetLabelForCommandId(1)); | 110 EXPECT_EQ(base::string16(), menu_model()->GetLabelForCommandId(1)); |
111 EXPECT_EQ(base::string16(), menu_model()->GetSublabelForCommandId(0)); | 111 EXPECT_EQ(base::string16(), menu_model()->GetSublabelForCommandId(0)); |
112 EXPECT_FALSE(menu_model()->GetIconForCommandId(0, &image_arg)); | 112 EXPECT_FALSE(menu_model()->GetIconForCommandId(0, &image_arg)); |
113 | 113 |
114 // Menu state should have changed 7 times in this test. | 114 // Menu state should have changed 7 times in this test. |
115 EXPECT_EQ(7, changed_count()); | 115 EXPECT_EQ(7, changed_count()); |
116 } | 116 } |
OLD | NEW |