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

Unified Diff: ui/views/controls/menu/menu_runner_cocoa_unittest.mm

Issue 1876013002: Fixed potential crash on destroying MenuRunnerImplCocoa. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review fixes. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_runner_impl_cocoa.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/menu/menu_runner_cocoa_unittest.mm
diff --git a/ui/views/controls/menu/menu_runner_cocoa_unittest.mm b/ui/views/controls/menu/menu_runner_cocoa_unittest.mm
index 73e02eca385483f7d2994d045400cde586568f53..852a6debe46ae27806c3b96e90858f3ddd7ec9ab 100644
--- a/ui/views/controls/menu/menu_runner_cocoa_unittest.mm
+++ b/ui/views/controls/menu/menu_runner_cocoa_unittest.mm
@@ -137,6 +137,12 @@ class MenuRunnerCocoaTest : public ViewsTestBase {
runner_ = nullptr;
}
+ void MenuCancelAndDeleteCallback() {
+ runner_->Cancel();
+ runner_->Release();
+ runner_ = nullptr;
+ }
+
protected:
scoped_ptr<TestModel> menu_;
internal::MenuRunnerImplCocoa* runner_ = nullptr;
@@ -182,6 +188,15 @@ TEST_F(MenuRunnerCocoaTest, RunMenuAndDelete) {
EXPECT_EQ(MenuRunner::MENU_DELETED, result);
}
+// Ensure a menu can be safely released immediately after a call to Cancel() in
+// the same run loop iteration.
+TEST_F(MenuRunnerCocoaTest, DestroyAfterCanceling) {
+ MenuRunner::RunResult result =
+ RunMenu(base::Bind(&MenuRunnerCocoaTest::MenuCancelAndDeleteCallback,
+ base::Unretained(this)));
+ EXPECT_EQ(MenuRunner::MENU_DELETED, result);
+}
+
TEST_F(MenuRunnerCocoaTest, RunMenuTwice) {
for (int i = 0; i < 2; ++i) {
MenuRunner::RunResult result = RunMenu(base::Bind(
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_runner_impl_cocoa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698