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 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 void TearDown() override { menu_->RemoveObserver(this); } |
30 menu_->RemoveObserver(this); | |
31 } | |
32 | 30 |
33 virtual int changed_count() { | 31 virtual int changed_count() { |
34 return changed_count_; | 32 return changed_count_; |
35 } | 33 } |
36 | 34 |
37 StatusIconMenuModel* menu_model() { | 35 StatusIconMenuModel* menu_model() { |
38 return menu_.get(); | 36 return menu_.get(); |
39 } | 37 } |
40 | 38 |
41 private: | 39 private: |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 103 |
106 // Ensure changes to one menu item does not affect the other menu item. | 104 // Ensure changes to one menu item does not affect the other menu item. |
107 EXPECT_FALSE(menu_model()->GetAcceleratorForCommandId(1, &accel_arg)); | 105 EXPECT_FALSE(menu_model()->GetAcceleratorForCommandId(1, &accel_arg)); |
108 EXPECT_EQ(base::string16(), menu_model()->GetLabelForCommandId(1)); | 106 EXPECT_EQ(base::string16(), menu_model()->GetLabelForCommandId(1)); |
109 EXPECT_EQ(base::string16(), menu_model()->GetSublabelForCommandId(0)); | 107 EXPECT_EQ(base::string16(), menu_model()->GetSublabelForCommandId(0)); |
110 EXPECT_FALSE(menu_model()->GetIconForCommandId(0, &image_arg)); | 108 EXPECT_FALSE(menu_model()->GetIconForCommandId(0, &image_arg)); |
111 | 109 |
112 // Menu state should have changed 7 times in this test. | 110 // Menu state should have changed 7 times in this test. |
113 EXPECT_EQ(7, changed_count()); | 111 EXPECT_EQ(7, changed_count()); |
114 } | 112 } |
OLD | NEW |