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