OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "chrome/browser/extensions/extension_install_prompt.h" | 7 #include "chrome/browser/extensions/extension_install_prompt.h" |
8 #include "chrome/browser/extensions/extension_reenabler.h" | 8 #include "chrome/browser/extensions/extension_reenabler.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_service_test_base.h" | 10 #include "chrome/browser/extensions/extension_service_test_base.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 // Get a callback to run on the completion of the reenable process and reset | 52 // Get a callback to run on the completion of the reenable process and reset |
53 // |result_|. | 53 // |result_|. |
54 ExtensionReenabler::Callback GetCallback() { | 54 ExtensionReenabler::Callback GetCallback() { |
55 result_.reset(); | 55 result_.reset(); |
56 return base::Bind(&CallbackHelper::OnComplete, | 56 return base::Bind(&CallbackHelper::OnComplete, |
57 base::Unretained(this)); | 57 base::Unretained(this)); |
58 } | 58 } |
59 | 59 |
60 // Check if we have receved any result, and if it matches the expected one. | 60 // Check if we have receved any result, and if it matches the expected one. |
61 bool has_result() const { return result_.get() != nullptr; } | 61 bool has_result() const { return result_ != nullptr; } |
62 bool result_matches(ExtensionReenabler::ReenableResult expected) const { | 62 bool result_matches(ExtensionReenabler::ReenableResult expected) const { |
63 return result_.get() && *result_ == expected; | 63 return result_.get() && *result_ == expected; |
64 } | 64 } |
65 | 65 |
66 // Create a test ExtensionInstallPrompt that will not display any UI (which | 66 // Create a test ExtensionInstallPrompt that will not display any UI (which |
67 // causes unit tests to crash), but rather runs the given |quit_closure| (with | 67 // causes unit tests to crash), but rather runs the given |quit_closure| (with |
68 // the prompt still active|. | 68 // the prompt still active|. |
69 ExtensionInstallPrompt::ShowDialogCallback CreateShowCallback( | 69 ExtensionInstallPrompt::ShowDialogCallback CreateShowCallback( |
70 const base::Closure& quit_closure) { | 70 const base::Closure& quit_closure) { |
71 quit_closure_ = quit_closure; | 71 quit_closure_ = quit_closure; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 EXPECT_FALSE(callback_helper.has_result()); | 259 EXPECT_FALSE(callback_helper.has_result()); |
260 // Destroy the reenabler to simulate the owning context being shut down | 260 // Destroy the reenabler to simulate the owning context being shut down |
261 // (e.g., the tab closing). | 261 // (e.g., the tab closing). |
262 extension_reenabler.reset(); | 262 extension_reenabler.reset(); |
263 EXPECT_TRUE( | 263 EXPECT_TRUE( |
264 callback_helper.result_matches(ExtensionReenabler::ABORTED)); | 264 callback_helper.result_matches(ExtensionReenabler::ABORTED)); |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 } // namespace extensions | 268 } // namespace extensions |
OLD | NEW |