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

Side by Side Diff: chrome/browser/autofill/content_autofill_driver_browsertest.cc

Issue 707173004: Refactor Autofill for out of process iframes (OOPIF). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mem leak Created 6 years 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
OLDNEW
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/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "chrome/browser/browser_process.h" 6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_tabstrip.h" 8 #include "chrome/browser/ui/browser_tabstrip.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" 9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
11 #include "chrome/test/base/in_process_browser_test.h" 11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/testing_pref_service_syncable.h" 12 #include "chrome/test/base/testing_pref_service_syncable.h"
13 #include "components/autofill/content/browser/content_autofill_driver.h" 13 #include "components/autofill/content/browser/content_autofill_driver.h"
14 #include "components/autofill/content/browser/content_autofill_driver_factory.h"
14 #include "components/autofill/core/browser/autofill_manager.h" 15 #include "components/autofill/core/browser/autofill_manager.h"
15 #include "components/autofill/core/browser/test_autofill_client.h" 16 #include "components/autofill/core/browser/test_autofill_client.h"
16 #include "content/public/browser/navigation_controller.h" 17 #include "content/public/browser/navigation_controller.h"
17 #include "content/public/browser/page_navigator.h" 18 #include "content/public/browser/page_navigator.h"
18 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
19 #include "content/public/browser/web_contents_observer.h" 20 #include "content/public/browser/web_contents_observer.h"
20 #include "content/public/common/url_constants.h" 21 #include "content/public/common/url_constants.h"
21 #include "content/public/test/test_utils.h" 22 #include "content/public/test/test_utils.h"
22 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 27 matching lines...) Expand all
51 private: 52 private:
52 TestingPrefServiceSyncable prefs_; 53 TestingPrefServiceSyncable prefs_;
53 54
54 DISALLOW_COPY_AND_ASSIGN(MockAutofillClient); 55 DISALLOW_COPY_AND_ASSIGN(MockAutofillClient);
55 }; 56 };
56 57
57 // Subclass ContentAutofillDriver so we can create an ContentAutofillDriver 58 // Subclass ContentAutofillDriver so we can create an ContentAutofillDriver
58 // instance. 59 // instance.
59 class TestContentAutofillDriver : public ContentAutofillDriver { 60 class TestContentAutofillDriver : public ContentAutofillDriver {
60 public: 61 public:
61 TestContentAutofillDriver(content::WebContents* web_contents, 62 TestContentAutofillDriver(content::RenderFrameHost* rfh,
62 AutofillClient* client) 63 AutofillClient* client)
63 : ContentAutofillDriver( 64 : ContentAutofillDriver(
64 web_contents, 65 rfh,
65 client, 66 client,
66 g_browser_process->GetApplicationLocale(), 67 g_browser_process->GetApplicationLocale(),
67 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER) {} 68 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER) {}
68 ~TestContentAutofillDriver() override {} 69 ~TestContentAutofillDriver() override {}
69 70
70 private: 71 private:
71 DISALLOW_COPY_AND_ASSIGN(TestContentAutofillDriver); 72 DISALLOW_COPY_AND_ASSIGN(TestContentAutofillDriver);
72 }; 73 };
73 74
74 } // namespace 75 } // namespace
75 76
76 class ContentAutofillDriverBrowserTest : public InProcessBrowserTest, 77 class ContentAutofillDriverBrowserTest : public InProcessBrowserTest,
77 public content::WebContentsObserver { 78 public content::WebContentsObserver {
78 public: 79 public:
79 ContentAutofillDriverBrowserTest() {} 80 ContentAutofillDriverBrowserTest() {}
80 virtual ~ContentAutofillDriverBrowserTest() {} 81 virtual ~ContentAutofillDriverBrowserTest() {}
81 82
82 virtual void SetUpOnMainThread() override { 83 virtual void SetUpOnMainThread() override {
83 content::WebContents* web_contents = 84 content::WebContents* web_contents =
84 browser()->tab_strip_model()->GetActiveWebContents(); 85 browser()->tab_strip_model()->GetActiveWebContents();
85 ASSERT_TRUE(web_contents != NULL); 86 ASSERT_TRUE(web_contents != NULL);
86 Observe(web_contents); 87 Observe(web_contents);
87 AutofillManager::RegisterProfilePrefs(autofill_client_.GetPrefRegistry()); 88 AutofillManager::RegisterProfilePrefs(autofill_client_.GetPrefRegistry());
88 89
89 autofill_driver_.reset( 90 web_contents->RemoveUserData(
90 new TestContentAutofillDriver(web_contents, &autofill_client_)); 91 ContentAutofillDriverFactory::
91 } 92 kContentAutofillDriverFactoryWebContentsUserDataKey);
92 93 ContentAutofillDriverFactory::CreateForWebContentsAndDelegate(
93 // Normally the WebContents will automatically delete the driver, but here 94 web_contents, &autofill_client_, "en-US",
94 // the driver is owned by this test, so we have to manually destroy. 95 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER);
95 virtual void WebContentsDestroyed() override {
96 autofill_driver_.reset();
97 } 96 }
98 97
99 virtual void WasHidden() override { 98 virtual void WasHidden() override {
100 if (!web_contents_hidden_callback_.is_null()) 99 if (!web_contents_hidden_callback_.is_null())
101 web_contents_hidden_callback_.Run(); 100 web_contents_hidden_callback_.Run();
102 } 101 }
103 102
104 virtual void NavigationEntryCommitted( 103 virtual void NavigationEntryCommitted(
105 const content::LoadCommittedDetails& load_details) override { 104 const content::LoadCommittedDetails& load_details) override {
106 if (!nav_entry_committed_callback_.is_null()) 105 if (!nav_entry_committed_callback_.is_null())
107 nav_entry_committed_callback_.Run(); 106 nav_entry_committed_callback_.Run();
108 } 107 }
109 108
110 protected: 109 protected:
111 content::WebContents* web_contents_; 110 content::WebContents* web_contents_;
112 111
113 base::Closure web_contents_hidden_callback_; 112 base::Closure web_contents_hidden_callback_;
114 base::Closure nav_entry_committed_callback_; 113 base::Closure nav_entry_committed_callback_;
115 114
116 testing::NiceMock<MockAutofillClient> autofill_client_; 115 testing::NiceMock<MockAutofillClient> autofill_client_;
117 scoped_ptr<TestContentAutofillDriver> autofill_driver_;
118 }; 116 };
119 117
120 IN_PROC_BROWSER_TEST_F(ContentAutofillDriverBrowserTest, 118 IN_PROC_BROWSER_TEST_F(ContentAutofillDriverBrowserTest,
121 SwitchTabAndHideAutofillPopup) { 119 SwitchTabAndHideAutofillPopup) {
122 // Notification is different on platforms. On linux this will be called twice, 120 // Notification is different on platforms. On linux this will be called twice,
123 // while on windows only once. 121 // while on windows only once.
124 EXPECT_CALL(autofill_client_, HideAutofillPopup()).Times(testing::AtLeast(1)); 122 EXPECT_CALL(autofill_client_, HideAutofillPopup()).Times(testing::AtLeast(1));
125 123
126 scoped_refptr<content::MessageLoopRunner> runner = 124 scoped_refptr<content::MessageLoopRunner> runner =
127 new content::MessageLoopRunner; 125 new content::MessageLoopRunner;
(...skipping 22 matching lines...) Expand all
150 browser()->OpenURL(content::OpenURLParams(GURL(chrome::kChromeUIAboutURL), 148 browser()->OpenURL(content::OpenURLParams(GURL(chrome::kChromeUIAboutURL),
151 content::Referrer(), 149 content::Referrer(),
152 CURRENT_TAB, 150 CURRENT_TAB,
153 ui::PAGE_TRANSITION_TYPED, 151 ui::PAGE_TRANSITION_TYPED,
154 false)); 152 false));
155 runner->Run(); 153 runner->Run();
156 nav_entry_committed_callback_.Reset(); 154 nav_entry_committed_callback_.Reset();
157 } 155 }
158 156
159 } // namespace autofill 157 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_interactive_uitest.cc ('k') | chrome/browser/autofill/form_structure_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698