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

Side by Side Diff: chrome/browser/ui/global_error/global_error_service_unittest.cc

Issue 11150002: New post-sideload UI: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: !!! Created 8 years, 2 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
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 "chrome/browser/ui/global_error/global_error_service.h" 5 #include "chrome/browser/ui/global_error/global_error_service.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/ui/global_error/global_error.h" 9 #include "chrome/browser/ui/global_error/global_error.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 DISALLOW_COPY_AND_ASSIGN(BaseError); 78 DISALLOW_COPY_AND_ASSIGN(BaseError);
79 }; 79 };
80 80
81 int BaseError::count_ = 0; 81 int BaseError::count_ = 0;
82 82
83 // A simple error that only has a badge. 83 // A simple error that only has a badge.
84 class BadgeError : public BaseError { 84 class BadgeError : public BaseError {
85 public: 85 public:
86 explicit BadgeError(int resource_id) : resource_id_(resource_id) {} 86 explicit BadgeError(int resource_id) : resource_id_(resource_id) {}
87 bool HasBadge() OVERRIDE { return true; } 87 bool HasBadge() OVERRIDE { return true; }
88 Severity GetSeverity() OVERRIDE {
89 return static_cast<Severity>(resource_id_);
90 }
88 virtual int GetBadgeResourceID() OVERRIDE { return resource_id_; } 91 virtual int GetBadgeResourceID() OVERRIDE { return resource_id_; }
89 92
90 private: 93 private:
91 int resource_id_; 94 int resource_id_;
92 95
93 DISALLOW_COPY_AND_ASSIGN(BadgeError); 96 DISALLOW_COPY_AND_ASSIGN(BadgeError);
94 }; 97 };
95 98
96 // A simple error that only has a menu item. 99 // A simple error that only has a menu item.
97 class MenuError : public BaseError { 100 class MenuError : public BaseError {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 service.AddGlobalError(error3); 169 service.AddGlobalError(error3);
167 170
168 EXPECT_EQ(error2, service.GetGlobalErrorByMenuItemCommandID(2)); 171 EXPECT_EQ(error2, service.GetGlobalErrorByMenuItemCommandID(2));
169 EXPECT_EQ(error3, service.GetGlobalErrorByMenuItemCommandID(3)); 172 EXPECT_EQ(error3, service.GetGlobalErrorByMenuItemCommandID(3));
170 EXPECT_EQ(NULL, service.GetGlobalErrorByMenuItemCommandID(4)); 173 EXPECT_EQ(NULL, service.GetGlobalErrorByMenuItemCommandID(4));
171 } 174 }
172 175
173 // Test getting the badge icon resource ID of the first error. 176 // Test getting the badge icon resource ID of the first error.
174 TEST(GlobalErrorServiceTest, GetBadgeID) { 177 TEST(GlobalErrorServiceTest, GetBadgeID) {
175 BaseError* error1 = new BaseError; 178 BaseError* error1 = new BaseError;
176 BadgeError error2(2); 179 BadgeError* error2 = new BadgeError(2);
177 BadgeError* error3 = new BadgeError(3); 180 BadgeError* error3 = new BadgeError(3);
181 BadgeError* error4 = new BadgeError(4);
178 182
179 GlobalErrorService service(NULL); 183 GlobalErrorService service(NULL);
180 EXPECT_EQ(0, service.GetFirstBadgeResourceID()); 184 EXPECT_EQ(0, service.GetFirstBadgeResourceID());
181 185
182 service.AddGlobalError(error1); 186 service.AddGlobalError(error1);
183 EXPECT_EQ(0, service.GetFirstBadgeResourceID()); 187 EXPECT_EQ(0, service.GetFirstBadgeResourceID());
184 188
185 service.AddGlobalError(&error2); 189 service.AddGlobalError(error2);
186 EXPECT_EQ(2, service.GetFirstBadgeResourceID()); 190 EXPECT_EQ(2, service.GetFirstBadgeResourceID());
187 191
192 service.AddGlobalError(error4);
193 EXPECT_EQ(4, service.GetFirstBadgeResourceID());
194
188 service.AddGlobalError(error3); 195 service.AddGlobalError(error3);
189 EXPECT_EQ(2, service.GetFirstBadgeResourceID()); 196 EXPECT_EQ(4, service.GetFirstBadgeResourceID());
190 197
191 // Remove the first error with a badge. 198 // Remove the highest-severity error with a badge.
192 service.RemoveGlobalError(&error2); 199 service.RemoveGlobalError(error4);
200 delete error4;
201
193 // Now error3 should be the first error with a badge. 202 // Now error3 should be the first error with a badge.
194 EXPECT_EQ(3, service.GetFirstBadgeResourceID()); 203 EXPECT_EQ(3, service.GetFirstBadgeResourceID());
195 } 204 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/global_error/global_error_service.cc ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698