| 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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/global_error/global_error.h" | 9 #include "chrome/browser/ui/global_error/global_error.h" |
| 10 #include "chrome/browser/ui/global_error/global_error_bubble_view_base.h" | 10 #include "chrome/browser/ui/global_error/global_error_bubble_view_base.h" |
| 11 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 11 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 12 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // An error that has a bubble view. | 17 // An error that has a bubble view. |
| 18 class BubbleViewError : public GlobalErrorWithStandardBubble { | 18 class BubbleViewError : public GlobalErrorWithStandardBubble { |
| 19 public: | 19 public: |
| 20 BubbleViewError() : bubble_view_close_count_(0) { } | 20 BubbleViewError() : bubble_view_close_count_(0) { } |
| 21 | 21 |
| 22 int bubble_view_close_count() { return bubble_view_close_count_; } | 22 int bubble_view_close_count() { return bubble_view_close_count_; } |
| 23 | 23 |
| 24 virtual bool HasMenuItem() OVERRIDE { return false; } | 24 virtual bool HasMenuItem() override { return false; } |
| 25 virtual int MenuItemCommandID() OVERRIDE { | 25 virtual int MenuItemCommandID() override { |
| 26 ADD_FAILURE(); | 26 ADD_FAILURE(); |
| 27 return 0; | 27 return 0; |
| 28 } | 28 } |
| 29 virtual base::string16 MenuItemLabel() OVERRIDE { | 29 virtual base::string16 MenuItemLabel() override { |
| 30 ADD_FAILURE(); | 30 ADD_FAILURE(); |
| 31 return base::string16(); | 31 return base::string16(); |
| 32 } | 32 } |
| 33 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE { ADD_FAILURE(); } | 33 virtual void ExecuteMenuItem(Browser* browser) override { ADD_FAILURE(); } |
| 34 | 34 |
| 35 virtual bool HasBubbleView() OVERRIDE { return true; } | 35 virtual bool HasBubbleView() override { return true; } |
| 36 virtual base::string16 GetBubbleViewTitle() OVERRIDE { | 36 virtual base::string16 GetBubbleViewTitle() override { |
| 37 return base::string16(); | 37 return base::string16(); |
| 38 } | 38 } |
| 39 virtual std::vector<base::string16> GetBubbleViewMessages() OVERRIDE { | 39 virtual std::vector<base::string16> GetBubbleViewMessages() override { |
| 40 return std::vector<base::string16>(); | 40 return std::vector<base::string16>(); |
| 41 } | 41 } |
| 42 virtual base::string16 GetBubbleViewAcceptButtonLabel() OVERRIDE { | 42 virtual base::string16 GetBubbleViewAcceptButtonLabel() override { |
| 43 return base::string16(); | 43 return base::string16(); |
| 44 } | 44 } |
| 45 virtual base::string16 GetBubbleViewCancelButtonLabel() OVERRIDE { | 45 virtual base::string16 GetBubbleViewCancelButtonLabel() override { |
| 46 return base::string16(); | 46 return base::string16(); |
| 47 } | 47 } |
| 48 virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE { | 48 virtual void OnBubbleViewDidClose(Browser* browser) override { |
| 49 EXPECT_TRUE(browser); | 49 EXPECT_TRUE(browser); |
| 50 ++bubble_view_close_count_; | 50 ++bubble_view_close_count_; |
| 51 } | 51 } |
| 52 virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE {} | 52 virtual void BubbleViewAcceptButtonPressed(Browser* browser) override {} |
| 53 virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE {} | 53 virtual void BubbleViewCancelButtonPressed(Browser* browser) override {} |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 int bubble_view_close_count_; | 56 int bubble_view_close_count_; |
| 57 | 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(BubbleViewError); | 58 DISALLOW_COPY_AND_ASSIGN(BubbleViewError); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 } // namespace | 61 } // namespace |
| 62 | 62 |
| 63 class GlobalErrorServiceBrowserTest : public InProcessBrowserTest { | 63 class GlobalErrorServiceBrowserTest : public InProcessBrowserTest { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 EXPECT_TRUE(error->HasShownBubbleView()); | 132 EXPECT_TRUE(error->HasShownBubbleView()); |
| 133 EXPECT_EQ(0, error->bubble_view_close_count()); | 133 EXPECT_EQ(0, error->bubble_view_close_count()); |
| 134 | 134 |
| 135 // Removing |error| from profile should dismiss the bubble view without | 135 // Removing |error| from profile should dismiss the bubble view without |
| 136 // calling |error->BubbleViewDidClose|. | 136 // calling |error->BubbleViewDidClose|. |
| 137 service->RemoveGlobalError(error.get()); | 137 service->RemoveGlobalError(error.get()); |
| 138 content::RunAllPendingInMessageLoop(); | 138 content::RunAllPendingInMessageLoop(); |
| 139 EXPECT_EQ(1, error->bubble_view_close_count()); | 139 EXPECT_EQ(1, error->bubble_view_close_count()); |
| 140 // |error| is no longer owned by service and will be deleted. | 140 // |error| is no longer owned by service and will be deleted. |
| 141 } | 141 } |
| OLD | NEW |