OLD | NEW |
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" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
| 13 #include "components/autofill/browser/autofill_common_test.h" |
13 #include "components/autofill/common/form_data.h" | 14 #include "components/autofill/common/form_data.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "content/public/browser/web_contents_view.h" | 16 #include "content/public/browser/web_contents_view.h" |
16 #include "content/public/test/test_utils.h" | 17 #include "content/public/test/test_utils.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace autofill { | 20 namespace autofill { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController); | 71 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController); |
71 }; | 72 }; |
72 | 73 |
73 class AutofillDialogCocoaBrowserTest : public InProcessBrowserTest { | 74 class AutofillDialogCocoaBrowserTest : public InProcessBrowserTest { |
74 public: | 75 public: |
75 AutofillDialogCocoaBrowserTest() : InProcessBrowserTest() {} | 76 AutofillDialogCocoaBrowserTest() : InProcessBrowserTest() {} |
76 | 77 |
77 virtual ~AutofillDialogCocoaBrowserTest() {} | 78 virtual ~AutofillDialogCocoaBrowserTest() {} |
78 | 79 |
79 virtual void SetUpOnMainThread() OVERRIDE { | 80 virtual void SetUpOnMainThread() OVERRIDE { |
| 81 // Ensure Mac OS X does not pop up a modal dialog for the Address Book. |
| 82 autofill::test::DisableSystemServices(browser()->profile()); |
| 83 |
80 FormFieldData field; | 84 FormFieldData field; |
81 field.autocomplete_attribute = "cc-number"; | 85 field.autocomplete_attribute = "cc-number"; |
82 FormData form_data; | 86 FormData form_data; |
83 form_data.fields.push_back(field); | 87 form_data.fields.push_back(field); |
84 runner_ = new content::MessageLoopRunner; | 88 runner_ = new content::MessageLoopRunner; |
85 controller_ = new TestAutofillDialogController( | 89 controller_ = new TestAutofillDialogController( |
86 browser()->tab_strip_model()->GetActiveWebContents(), | 90 browser()->tab_strip_model()->GetActiveWebContents(), |
87 form_data, | 91 form_data, |
88 metric_logger_, | 92 metric_logger_, |
89 runner_, | 93 runner_, |
90 DIALOG_TYPE_REQUEST_AUTOCOMPLETE); | 94 DIALOG_TYPE_REQUEST_AUTOCOMPLETE); |
91 } | 95 } |
92 | 96 |
93 TestAutofillDialogController* controller() { return controller_; } | 97 TestAutofillDialogController* controller() { return controller_; } |
94 | 98 |
95 private: | 99 private: |
96 // The controller owns itself. | 100 // The controller owns itself. |
97 TestAutofillDialogController* controller_; | 101 TestAutofillDialogController* controller_; |
98 | 102 |
99 // The following members must outlive the controller. | 103 // The following members must outlive the controller. |
100 AutofillMetrics metric_logger_; | 104 AutofillMetrics metric_logger_; |
101 scoped_refptr<content::MessageLoopRunner> runner_; | 105 scoped_refptr<content::MessageLoopRunner> runner_; |
102 | 106 |
103 DISALLOW_COPY_AND_ASSIGN(AutofillDialogCocoaBrowserTest); | 107 DISALLOW_COPY_AND_ASSIGN(AutofillDialogCocoaBrowserTest); |
104 }; | 108 }; |
105 | 109 |
106 // The following test fails under ASAN. Disabling until root cause is found. | 110 // The following test fails under ASAN due to a read-after-free. |
107 // This can pop up a "browser_tests would like access to your Contacts" dialog. | 111 // http://crbug.com/234008 |
108 // See also http://crbug.com/234008. | |
109 #if defined(ADDRESS_SANITIZER) | 112 #if defined(ADDRESS_SANITIZER) |
110 #define MAYBE_DisplayUI DISABLED_DisplayUI | 113 #define MAYBE_DisplayUI DISABLED_DisplayUI |
111 #else | 114 #else |
112 #define MAYBE_DisplayUI DisplayUI | 115 #define MAYBE_DisplayUI DisplayUI |
113 #endif | 116 #endif |
114 IN_PROC_BROWSER_TEST_F(AutofillDialogCocoaBrowserTest, MAYBE_DisplayUI) { | 117 IN_PROC_BROWSER_TEST_F(AutofillDialogCocoaBrowserTest, MAYBE_DisplayUI) { |
115 controller()->Show(); | 118 controller()->Show(); |
116 controller()->OnCancel(); | 119 controller()->OnCancel(); |
117 controller()->Hide(); | 120 controller()->Hide(); |
118 | 121 |
119 controller()->RunMessageLoop(); | 122 controller()->RunMessageLoop(); |
120 } | 123 } |
121 | 124 |
122 } // namespace | 125 } // namespace |
123 | 126 |
124 } // namespace autofill | 127 } // namespace autofill |
OLD | NEW |