| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 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 void OnMenuStateChanged() override { ++changed_count_; } |
| 43 ++changed_count_; | |
| 44 } | |
| 45 | 43 |
| 46 scoped_ptr<StatusIconMenuModel> menu_; | 44 scoped_ptr<StatusIconMenuModel> menu_; |
| 47 int changed_count_; | 45 int changed_count_; |
| 48 }; | 46 }; |
| 49 | 47 |
| 50 TEST_F(StatusIconMenuModelTest, ToggleBooleanProperties) { | 48 TEST_F(StatusIconMenuModelTest, ToggleBooleanProperties) { |
| 51 menu_model()->AddItem(0, ASCIIToUTF16("foo")); | 49 menu_model()->AddItem(0, ASCIIToUTF16("foo")); |
| 52 | 50 |
| 53 menu_model()->SetCommandIdChecked(0, true); | 51 menu_model()->SetCommandIdChecked(0, true); |
| 54 EXPECT_TRUE(menu_model()->IsCommandIdChecked(0)); | 52 EXPECT_TRUE(menu_model()->IsCommandIdChecked(0)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 105 |
| 108 // Ensure changes to one menu item does not affect the other menu item. | 106 // Ensure changes to one menu item does not affect the other menu item. |
| 109 EXPECT_FALSE(menu_model()->GetAcceleratorForCommandId(1, &accel_arg)); | 107 EXPECT_FALSE(menu_model()->GetAcceleratorForCommandId(1, &accel_arg)); |
| 110 EXPECT_EQ(base::string16(), menu_model()->GetLabelForCommandId(1)); | 108 EXPECT_EQ(base::string16(), menu_model()->GetLabelForCommandId(1)); |
| 111 EXPECT_EQ(base::string16(), menu_model()->GetSublabelForCommandId(0)); | 109 EXPECT_EQ(base::string16(), menu_model()->GetSublabelForCommandId(0)); |
| 112 EXPECT_FALSE(menu_model()->GetIconForCommandId(0, &image_arg)); | 110 EXPECT_FALSE(menu_model()->GetIconForCommandId(0, &image_arg)); |
| 113 | 111 |
| 114 // Menu state should have changed 7 times in this test. | 112 // Menu state should have changed 7 times in this test. |
| 115 EXPECT_EQ(7, changed_count()); | 113 EXPECT_EQ(7, changed_count()); |
| 116 } | 114 } |
| OLD | NEW |