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

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

Issue 648653003: Standardize usage of virtual/override/final in chrome/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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/macros.h" 5 #include "base/macros.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/autofill/personal_data_manager_factory.h" 10 #include "chrome/browser/autofill/personal_data_manager_factory.h"
(...skipping 17 matching lines...) Expand all
28 28
29 // TODO(isherman): Similar classes are defined in a few other Autofill browser 29 // TODO(isherman): Similar classes are defined in a few other Autofill browser
30 // tests. It would be good to factor out the shared code into a helper file. 30 // tests. It would be good to factor out the shared code into a helper file.
31 class WindowedPersonalDataManagerObserver : public PersonalDataManagerObserver { 31 class WindowedPersonalDataManagerObserver : public PersonalDataManagerObserver {
32 public: 32 public:
33 explicit WindowedPersonalDataManagerObserver(Profile* profile) 33 explicit WindowedPersonalDataManagerObserver(Profile* profile)
34 : profile_(profile), 34 : profile_(profile),
35 message_loop_runner_(new content::MessageLoopRunner){ 35 message_loop_runner_(new content::MessageLoopRunner){
36 PersonalDataManagerFactory::GetForProfile(profile_)->AddObserver(this); 36 PersonalDataManagerFactory::GetForProfile(profile_)->AddObserver(this);
37 } 37 }
38 virtual ~WindowedPersonalDataManagerObserver() {} 38 ~WindowedPersonalDataManagerObserver() override {}
39 39
40 // Waits for the PersonalDataManager's list of profiles to be updated. 40 // Waits for the PersonalDataManager's list of profiles to be updated.
41 void Wait() { 41 void Wait() {
42 message_loop_runner_->Run(); 42 message_loop_runner_->Run();
43 PersonalDataManagerFactory::GetForProfile(profile_)->RemoveObserver(this); 43 PersonalDataManagerFactory::GetForProfile(profile_)->RemoveObserver(this);
44 } 44 }
45 45
46 // PersonalDataManagerObserver: 46 // PersonalDataManagerObserver:
47 virtual void OnPersonalDataChanged() override { 47 void OnPersonalDataChanged() override { message_loop_runner_->Quit(); }
48 message_loop_runner_->Quit();
49 }
50 48
51 private: 49 private:
52 Profile* profile_; 50 Profile* profile_;
53 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 51 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
54 }; 52 };
55 53
56 class WindowedNetworkObserver : public net::TestURLFetcher::DelegateForTests { 54 class WindowedNetworkObserver : public net::TestURLFetcher::DelegateForTests {
57 public: 55 public:
58 explicit WindowedNetworkObserver(const std::string& expected_upload_data) 56 explicit WindowedNetworkObserver(const std::string& expected_upload_data)
59 : factory_(new net::TestURLFetcherFactory), 57 : factory_(new net::TestURLFetcherFactory),
60 expected_upload_data_(expected_upload_data), 58 expected_upload_data_(expected_upload_data),
61 message_loop_runner_(new content::MessageLoopRunner) { 59 message_loop_runner_(new content::MessageLoopRunner) {
62 factory_->SetDelegateForTests(this); 60 factory_->SetDelegateForTests(this);
63 } 61 }
64 ~WindowedNetworkObserver() {} 62 ~WindowedNetworkObserver() {}
65 63
66 // Waits for a network request with the |expected_upload_data_|. 64 // Waits for a network request with the |expected_upload_data_|.
67 void Wait() { 65 void Wait() {
68 message_loop_runner_->Run(); 66 message_loop_runner_->Run();
69 factory_.reset(); 67 factory_.reset();
70 } 68 }
71 69
72 // net::TestURLFetcher::DelegateForTests: 70 // net::TestURLFetcher::DelegateForTests:
73 virtual void OnRequestStart(int fetcher_id) override { 71 void OnRequestStart(int fetcher_id) override {
74 net::TestURLFetcher* fetcher = factory_->GetFetcherByID(fetcher_id); 72 net::TestURLFetcher* fetcher = factory_->GetFetcherByID(fetcher_id);
75 if (fetcher->upload_data() == expected_upload_data_) 73 if (fetcher->upload_data() == expected_upload_data_)
76 message_loop_runner_->Quit(); 74 message_loop_runner_->Quit();
77 75
78 // Not interested in any further status updates from this fetcher. 76 // Not interested in any further status updates from this fetcher.
79 fetcher->SetDelegateForTests(NULL); 77 fetcher->SetDelegateForTests(NULL);
80 } 78 }
81 virtual void OnChunkUpload(int fetcher_id) override {} 79 void OnChunkUpload(int fetcher_id) override {}
82 virtual void OnRequestEnd(int fetcher_id) override {} 80 void OnRequestEnd(int fetcher_id) override {}
83 81
84 private: 82 private:
85 // Mocks out network requests. 83 // Mocks out network requests.
86 scoped_ptr<net::TestURLFetcherFactory> factory_; 84 scoped_ptr<net::TestURLFetcherFactory> factory_;
87 85
88 const std::string expected_upload_data_; 86 const std::string expected_upload_data_;
89 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 87 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
90 88
91 DISALLOW_COPY_AND_ASSIGN(WindowedNetworkObserver); 89 DISALLOW_COPY_AND_ASSIGN(WindowedNetworkObserver);
92 }; 90 };
93 91
94 } // namespace 92 } // namespace
95 93
96 class AutofillServerTest : public InProcessBrowserTest { 94 class AutofillServerTest : public InProcessBrowserTest {
97 public: 95 public:
98 virtual void SetUpOnMainThread() override { 96 void SetUpOnMainThread() override {
99 // Disable interactions with the Mac Keychain. 97 // Disable interactions with the Mac Keychain.
100 PrefService* pref_service = browser()->profile()->GetPrefs(); 98 PrefService* pref_service = browser()->profile()->GetPrefs();
101 test::DisableSystemServices(pref_service); 99 test::DisableSystemServices(pref_service);
102 100
103 // Enable uploads, and load a new tab to force the AutofillDownloadManager 101 // Enable uploads, and load a new tab to force the AutofillDownloadManager
104 // to update its cached view of the prefs. 102 // to update its cached view of the prefs.
105 pref_service->SetDouble(prefs::kAutofillPositiveUploadRate, 1.0); 103 pref_service->SetDouble(prefs::kAutofillPositiveUploadRate, 1.0);
106 pref_service->SetDouble(prefs::kAutofillNegativeUploadRate, 1.0); 104 pref_service->SetDouble(prefs::kAutofillNegativeUploadRate, 1.0);
107 AddBlankTabAndShow(browser()); 105 AddBlankTabAndShow(browser());
108 } 106 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 "</autofillupload>"; 163 "</autofillupload>";
166 WindowedNetworkObserver upload_network_observer(kUploadRequest); 164 WindowedNetworkObserver upload_network_observer(kUploadRequest);
167 content::WebContents* web_contents = 165 content::WebContents* web_contents =
168 browser()->tab_strip_model()->GetActiveWebContents(); 166 browser()->tab_strip_model()->GetActiveWebContents();
169 content::SimulateMouseClick( 167 content::SimulateMouseClick(
170 web_contents, 0, blink::WebMouseEvent::ButtonLeft); 168 web_contents, 0, blink::WebMouseEvent::ButtonLeft);
171 upload_network_observer.Wait(); 169 upload_network_observer.Wait();
172 } 170 }
173 171
174 } // namespace autofill 172 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_interactive_uitest.cc ('k') | chrome/browser/autofill/content_autofill_driver_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698