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

Side by Side Diff: chrome/browser/status_icons/status_icon_menu_model_unittest.cc

Issue 464163003: Remove IDR_STATUS_TRAY_ICON_PRESSED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated the comment Created 6 years, 3 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
OLDNEW
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 EXPECT_EQ(7, changed_count()); 69 EXPECT_EQ(7, changed_count());
70 } 70 }
71 71
72 TEST_F(StatusIconMenuModelTest, SetProperties) { 72 TEST_F(StatusIconMenuModelTest, SetProperties) {
73 menu_model()->AddItem(0, ASCIIToUTF16("foo1")); 73 menu_model()->AddItem(0, ASCIIToUTF16("foo1"));
74 menu_model()->AddItem(1, ASCIIToUTF16("foo2")); 74 menu_model()->AddItem(1, ASCIIToUTF16("foo2"));
75 75
76 ui::Accelerator test_accel(ui::VKEY_A, ui::EF_NONE); 76 ui::Accelerator test_accel(ui::VKEY_A, ui::EF_NONE);
77 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 77 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
78 gfx::Image test_image1(*rb.GetImageSkiaNamed(IDR_STATUS_TRAY_ICON)); 78 gfx::Image test_image1(*rb.GetImageSkiaNamed(IDR_STATUS_TRAY_ICON));
79 gfx::Image test_image2(*rb.GetImageSkiaNamed(IDR_STATUS_TRAY_ICON_PRESSED));
80 ui::Accelerator accel_arg; 79 ui::Accelerator accel_arg;
81 gfx::Image image_arg; 80 gfx::Image image_arg;
82 81
83 EXPECT_FALSE(menu_model()->GetAcceleratorForCommandId(0, &accel_arg)); 82 EXPECT_FALSE(menu_model()->GetAcceleratorForCommandId(0, &accel_arg));
84 EXPECT_FALSE(menu_model()->GetIconForCommandId(0, &image_arg)); 83 EXPECT_FALSE(menu_model()->GetIconForCommandId(0, &image_arg));
85 EXPECT_FALSE(menu_model()->IsItemForCommandIdDynamic(0)); 84 EXPECT_FALSE(menu_model()->IsItemForCommandIdDynamic(0));
86 85
87 // Set the accelerator and label for the first menu item. 86 // Set the accelerator and label for the first menu item.
88 menu_model()->SetAcceleratorForCommandId(0, &test_accel); 87 menu_model()->SetAcceleratorForCommandId(0, &test_accel);
89 EXPECT_TRUE(menu_model()->GetAcceleratorForCommandId(0, &accel_arg)); 88 EXPECT_TRUE(menu_model()->GetAcceleratorForCommandId(0, &accel_arg));
90 EXPECT_EQ(test_accel, accel_arg); 89 EXPECT_EQ(test_accel, accel_arg);
91 90
92 // Try setting label and changing it. Also ensure that menu item is marked 91 // Try setting label and changing it. Also ensure that menu item is marked
93 // dynamic since the label has changed. 92 // dynamic since the label has changed.
94 menu_model()->ChangeLabelForCommandId(0, ASCIIToUTF16("label1")); 93 menu_model()->ChangeLabelForCommandId(0, ASCIIToUTF16("label1"));
95 EXPECT_TRUE(menu_model()->IsItemForCommandIdDynamic(0)); 94 EXPECT_TRUE(menu_model()->IsItemForCommandIdDynamic(0));
96 EXPECT_EQ(ASCIIToUTF16("label1"), menu_model()->GetLabelForCommandId(0)); 95 EXPECT_EQ(ASCIIToUTF16("label1"), menu_model()->GetLabelForCommandId(0));
97 menu_model()->ChangeLabelForCommandId(0, ASCIIToUTF16("label2")); 96 menu_model()->ChangeLabelForCommandId(0, ASCIIToUTF16("label2"));
98 EXPECT_EQ(ASCIIToUTF16("label2"), menu_model()->GetLabelForCommandId(0)); 97 EXPECT_EQ(ASCIIToUTF16("label2"), menu_model()->GetLabelForCommandId(0));
99 98
100 // Set the sublabel and icon image for the second menu item. 99 // Set the sublabel and icon image for the second menu item.
101 menu_model()->ChangeSublabelForCommandId(1, ASCIIToUTF16("sublabel")); 100 menu_model()->ChangeSublabelForCommandId(1, ASCIIToUTF16("sublabel"));
102 EXPECT_EQ(ASCIIToUTF16("sublabel"), menu_model()->GetSublabelForCommandId(1)); 101 EXPECT_EQ(ASCIIToUTF16("sublabel"), menu_model()->GetSublabelForCommandId(1));
103 102
104 // Try setting icon image and changing it. 103 // Try setting icon image and changing it.
105 menu_model()->ChangeIconForCommandId(1, test_image1); 104 menu_model()->ChangeIconForCommandId(1, test_image1);
106 EXPECT_TRUE(menu_model()->GetIconForCommandId(1, &image_arg)); 105 EXPECT_TRUE(menu_model()->GetIconForCommandId(1, &image_arg));
107 EXPECT_EQ(image_arg.ToImageSkia(), test_image1.ToImageSkia()); 106 EXPECT_EQ(image_arg.ToImageSkia(), test_image1.ToImageSkia());
108 menu_model()->ChangeIconForCommandId(1, test_image2);
109 EXPECT_TRUE(menu_model()->GetIconForCommandId(1, &image_arg));
110 EXPECT_EQ(image_arg.ToImageSkia(), test_image2.ToImageSkia());
111 107
112 // 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.
113 EXPECT_FALSE(menu_model()->GetAcceleratorForCommandId(1, &accel_arg)); 109 EXPECT_FALSE(menu_model()->GetAcceleratorForCommandId(1, &accel_arg));
114 EXPECT_EQ(base::string16(), menu_model()->GetLabelForCommandId(1)); 110 EXPECT_EQ(base::string16(), menu_model()->GetLabelForCommandId(1));
115 EXPECT_EQ(base::string16(), menu_model()->GetSublabelForCommandId(0)); 111 EXPECT_EQ(base::string16(), menu_model()->GetSublabelForCommandId(0));
116 EXPECT_FALSE(menu_model()->GetIconForCommandId(0, &image_arg)); 112 EXPECT_FALSE(menu_model()->GetIconForCommandId(0, &image_arg));
117 113
118 // Menu state should have changed 8 times in this test. 114 // Menu state should have changed 7 times in this test.
119 EXPECT_EQ(8, changed_count()); 115 EXPECT_EQ(7, changed_count());
120 } 116 }
OLDNEW
« no previous file with comments | « chrome/browser/status_icons/status_icon.h ('k') | chrome/browser/status_icons/status_icon_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698