| 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 <memory> |
| 8 |
| 7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/global_error/global_error.h" | 12 #include "chrome/browser/ui/global_error/global_error.h" |
| 12 #include "chrome/browser/ui/global_error/global_error_bubble_view_base.h" | 13 #include "chrome/browser/ui/global_error/global_error_bubble_view_base.h" |
| 13 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 14 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "content/public/test/test_utils.h" | 16 #include "content/public/test/test_utils.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // Test that bubble is silently dismissed if it is showing when the GlobalError | 114 // Test that bubble is silently dismissed if it is showing when the GlobalError |
| 114 // instance is removed from the profile. | 115 // instance is removed from the profile. |
| 115 #if defined(OS_WIN) || defined(OS_LINUX) | 116 #if defined(OS_WIN) || defined(OS_LINUX) |
| 116 // http://crbug.com/396473 | 117 // http://crbug.com/396473 |
| 117 #define MAYBE_BubbleViewDismissedOnRemove DISABLED_BubbleViewDismissedOnRemove | 118 #define MAYBE_BubbleViewDismissedOnRemove DISABLED_BubbleViewDismissedOnRemove |
| 118 #else | 119 #else |
| 119 #define MAYBE_BubbleViewDismissedOnRemove BubbleViewDismissedOnRemove | 120 #define MAYBE_BubbleViewDismissedOnRemove BubbleViewDismissedOnRemove |
| 120 #endif | 121 #endif |
| 121 IN_PROC_BROWSER_TEST_F(GlobalErrorServiceBrowserTest, | 122 IN_PROC_BROWSER_TEST_F(GlobalErrorServiceBrowserTest, |
| 122 MAYBE_BubbleViewDismissedOnRemove) { | 123 MAYBE_BubbleViewDismissedOnRemove) { |
| 123 scoped_ptr<BubbleViewError> error(new BubbleViewError); | 124 std::unique_ptr<BubbleViewError> error(new BubbleViewError); |
| 124 | 125 |
| 125 GlobalErrorService* service = | 126 GlobalErrorService* service = |
| 126 GlobalErrorServiceFactory::GetForProfile(browser()->profile()); | 127 GlobalErrorServiceFactory::GetForProfile(browser()->profile()); |
| 127 service->AddGlobalError(error.get()); | 128 service->AddGlobalError(error.get()); |
| 128 | 129 |
| 129 EXPECT_EQ(error.get(), service->GetFirstGlobalErrorWithBubbleView()); | 130 EXPECT_EQ(error.get(), service->GetFirstGlobalErrorWithBubbleView()); |
| 130 error->ShowBubbleView(browser()); | 131 error->ShowBubbleView(browser()); |
| 131 content::RunAllPendingInMessageLoop(); | 132 content::RunAllPendingInMessageLoop(); |
| 132 EXPECT_TRUE(error->HasShownBubbleView()); | 133 EXPECT_TRUE(error->HasShownBubbleView()); |
| 133 EXPECT_EQ(0, error->bubble_view_close_count()); | 134 EXPECT_EQ(0, error->bubble_view_close_count()); |
| 134 | 135 |
| 135 // Removing |error| from profile should dismiss the bubble view without | 136 // Removing |error| from profile should dismiss the bubble view without |
| 136 // calling |error->BubbleViewDidClose|. | 137 // calling |error->BubbleViewDidClose|. |
| 137 service->RemoveGlobalError(error.get()); | 138 service->RemoveGlobalError(error.get()); |
| 138 content::RunAllPendingInMessageLoop(); | 139 content::RunAllPendingInMessageLoop(); |
| 139 EXPECT_EQ(1, error->bubble_view_close_count()); | 140 EXPECT_EQ(1, error->bubble_view_close_count()); |
| 140 // |error| is no longer owned by service and will be deleted. | 141 // |error| is no longer owned by service and will be deleted. |
| 141 } | 142 } |
| OLD | NEW |