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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa_browsertest.mm

Issue 16054005: [ASAN] Fix use-after-free. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Enable test. Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #import "chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h" 4 #import "chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h"
5 5
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 9 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 27 matching lines...) Expand all
38 base::Bind(MockCallback)), 38 base::Bind(MockCallback)),
39 metric_logger_(metric_logger) , 39 metric_logger_(metric_logger) ,
40 runner_(runner) { 40 runner_(runner) {
41 DisableWallet(); 41 DisableWallet();
42 } 42 }
43 43
44 virtual ~TestAutofillDialogController() {} 44 virtual ~TestAutofillDialogController() {}
45 45
46 virtual void ViewClosed() OVERRIDE { 46 virtual void ViewClosed() OVERRIDE {
47 DCHECK(runner_); 47 DCHECK(runner_);
48 runner_->Quit();
48 AutofillDialogControllerImpl::ViewClosed(); 49 AutofillDialogControllerImpl::ViewClosed();
49 runner_->Quit();
50 }
51
52 void RunMessageLoop() {
53 DCHECK(runner_);
54 runner_->Run();
55 } 50 }
56 51
57 AutofillDialogCocoa* GetView() { 52 AutofillDialogCocoa* GetView() {
58 return static_cast<AutofillDialogCocoa*>( 53 return static_cast<AutofillDialogCocoa*>(
59 AutofillDialogControllerImpl::view()); 54 AutofillDialogControllerImpl::view());
60 } 55 }
61 56
62 private: 57 private:
63 // To specify our own metric logger. 58 // To specify our own metric logger.
64 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { 59 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE {
(...skipping 24 matching lines...) Expand all
89 controller_ = new TestAutofillDialogController( 84 controller_ = new TestAutofillDialogController(
90 browser()->tab_strip_model()->GetActiveWebContents(), 85 browser()->tab_strip_model()->GetActiveWebContents(),
91 form_data, 86 form_data,
92 metric_logger_, 87 metric_logger_,
93 runner_, 88 runner_,
94 DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 89 DIALOG_TYPE_REQUEST_AUTOCOMPLETE);
95 } 90 }
96 91
97 TestAutofillDialogController* controller() { return controller_; } 92 TestAutofillDialogController* controller() { return controller_; }
98 93
94 void RunMessageLoop() {
95 DCHECK(runner_);
96 runner_->Run();
97 }
98
99 private: 99 private:
100 // The controller owns itself. 100 // The controller owns itself.
101 TestAutofillDialogController* controller_; 101 TestAutofillDialogController* controller_;
102 102
103 // The following members must outlive the controller. 103 // The following members must outlive the controller.
104 AutofillMetrics metric_logger_; 104 AutofillMetrics metric_logger_;
105 scoped_refptr<content::MessageLoopRunner> runner_; 105 scoped_refptr<content::MessageLoopRunner> runner_;
106 106
107 DISALLOW_COPY_AND_ASSIGN(AutofillDialogCocoaBrowserTest); 107 DISALLOW_COPY_AND_ASSIGN(AutofillDialogCocoaBrowserTest);
108 }; 108 };
109 109
110 // The following test fails under ASAN due to a read-after-free. 110 IN_PROC_BROWSER_TEST_F(AutofillDialogCocoaBrowserTest, DisplayUI) {
111 // http://crbug.com/234008
112 #if defined(ADDRESS_SANITIZER)
113 #define MAYBE_DisplayUI DISABLED_DisplayUI
114 #else
115 #define MAYBE_DisplayUI DisplayUI
116 #endif
117 IN_PROC_BROWSER_TEST_F(AutofillDialogCocoaBrowserTest, MAYBE_DisplayUI) {
118 controller()->Show(); 111 controller()->Show();
119 controller()->OnCancel(); 112 controller()->OnCancel();
120 controller()->Hide(); 113 controller()->Hide();
121 114
122 controller()->RunMessageLoop(); 115 RunMessageLoop();
123 } 116 }
124 117
125 } // namespace 118 } // namespace
126 119
127 } // namespace autofill 120 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698