OLD | NEW |
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" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 // Error base class that keeps track of the number of errors that exist. | 14 // Error base class that keeps track of the number of errors that exist. |
15 class BaseError : public GlobalError { | 15 class BaseError : public GlobalError { |
16 public: | 16 public: |
17 BaseError() { ++count_; } | 17 BaseError() { ++count_; } |
18 virtual ~BaseError() { --count_; } | 18 virtual ~BaseError() { --count_; } |
19 | 19 |
20 static int count() { return count_; } | 20 static int count() { return count_; } |
21 | 21 |
22 virtual bool HasMenuItem() OVERRIDE { return false; } | 22 virtual bool HasMenuItem() override { return false; } |
23 virtual int MenuItemCommandID() OVERRIDE { | 23 virtual int MenuItemCommandID() override { |
24 ADD_FAILURE(); | 24 ADD_FAILURE(); |
25 return 0; | 25 return 0; |
26 } | 26 } |
27 virtual base::string16 MenuItemLabel() OVERRIDE { | 27 virtual base::string16 MenuItemLabel() override { |
28 ADD_FAILURE(); | 28 ADD_FAILURE(); |
29 return base::string16(); | 29 return base::string16(); |
30 } | 30 } |
31 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE { ADD_FAILURE(); } | 31 virtual void ExecuteMenuItem(Browser* browser) override { ADD_FAILURE(); } |
32 | 32 |
33 virtual bool HasBubbleView() OVERRIDE { return false; } | 33 virtual bool HasBubbleView() override { return false; } |
34 virtual bool HasShownBubbleView() OVERRIDE { return false; } | 34 virtual bool HasShownBubbleView() override { return false; } |
35 virtual void ShowBubbleView(Browser* browser) OVERRIDE { ADD_FAILURE(); } | 35 virtual void ShowBubbleView(Browser* browser) override { ADD_FAILURE(); } |
36 virtual GlobalErrorBubbleViewBase* GetBubbleView() OVERRIDE { return NULL; } | 36 virtual GlobalErrorBubbleViewBase* GetBubbleView() override { return NULL; } |
37 | 37 |
38 private: | 38 private: |
39 // This tracks the number BaseError objects that are currently instantiated. | 39 // This tracks the number BaseError objects that are currently instantiated. |
40 static int count_; | 40 static int count_; |
41 | 41 |
42 DISALLOW_COPY_AND_ASSIGN(BaseError); | 42 DISALLOW_COPY_AND_ASSIGN(BaseError); |
43 }; | 43 }; |
44 | 44 |
45 int BaseError::count_ = 0; | 45 int BaseError::count_ = 0; |
46 | 46 |
47 // A simple error that only has a menu item. | 47 // A simple error that only has a menu item. |
48 class MenuError : public BaseError { | 48 class MenuError : public BaseError { |
49 public: | 49 public: |
50 explicit MenuError(int command_id, Severity severity) | 50 explicit MenuError(int command_id, Severity severity) |
51 : command_id_(command_id), | 51 : command_id_(command_id), |
52 severity_(severity) { | 52 severity_(severity) { |
53 } | 53 } |
54 | 54 |
55 virtual Severity GetSeverity() OVERRIDE { return severity_; } | 55 virtual Severity GetSeverity() override { return severity_; } |
56 | 56 |
57 virtual bool HasMenuItem() OVERRIDE { return true; } | 57 virtual bool HasMenuItem() override { return true; } |
58 virtual int MenuItemCommandID() OVERRIDE { return command_id_; } | 58 virtual int MenuItemCommandID() override { return command_id_; } |
59 virtual base::string16 MenuItemLabel() OVERRIDE { return base::string16(); } | 59 virtual base::string16 MenuItemLabel() override { return base::string16(); } |
60 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE {} | 60 virtual void ExecuteMenuItem(Browser* browser) override {} |
61 | 61 |
62 private: | 62 private: |
63 int command_id_; | 63 int command_id_; |
64 Severity severity_; | 64 Severity severity_; |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(MenuError); | 66 DISALLOW_COPY_AND_ASSIGN(MenuError); |
67 }; | 67 }; |
68 | 68 |
69 } // namespace | 69 } // namespace |
70 | 70 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 service.AddGlobalError(error3); | 145 service.AddGlobalError(error3); |
146 EXPECT_EQ(error3, service.GetHighestSeverityGlobalErrorWithWrenchMenuItem()); | 146 EXPECT_EQ(error3, service.GetHighestSeverityGlobalErrorWithWrenchMenuItem()); |
147 | 147 |
148 // Remove the highest-severity error. | 148 // Remove the highest-severity error. |
149 service.RemoveGlobalError(error3); | 149 service.RemoveGlobalError(error3); |
150 delete error3; | 150 delete error3; |
151 | 151 |
152 // Now error2 should be the next highest severity error. | 152 // Now error2 should be the next highest severity error. |
153 EXPECT_EQ(error2, service.GetHighestSeverityGlobalErrorWithWrenchMenuItem()); | 153 EXPECT_EQ(error2, service.GetHighestSeverityGlobalErrorWithWrenchMenuItem()); |
154 } | 154 } |
OLD | NEW |