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

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

Issue 10542010: TabContentsWrapper -> TabContents, part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, rename Created 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <vector> 5 #include <vector>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" 11 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
12 #include "chrome/browser/autofill/autofill_common_test.h" 12 #include "chrome/browser/autofill/autofill_common_test.h"
13 #include "chrome/browser/autofill/autofill_manager.h" 13 #include "chrome/browser/autofill/autofill_manager.h"
14 #include "chrome/browser/autofill/autofill_metrics.h" 14 #include "chrome/browser/autofill/autofill_metrics.h"
15 #include "chrome/browser/autofill/personal_data_manager.h" 15 #include "chrome/browser/autofill/personal_data_manager.h"
16 #include "chrome/browser/autofill/personal_data_manager_factory.h" 16 #include "chrome/browser/autofill/personal_data_manager_factory.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
18 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" 18 #include "chrome/browser/ui/tab_contents/test_tab_contents.h"
19 #include "chrome/browser/webdata/web_data_service.h" 19 #include "chrome/browser/webdata/web_data_service.h"
20 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
21 #include "content/public/test/test_browser_thread.h" 21 #include "content/public/test/test_browser_thread.h"
22 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "ui/gfx/rect.h" 24 #include "ui/gfx/rect.h"
25 #include "webkit/forms/form_data.h" 25 #include "webkit/forms/form_data.h"
26 #include "webkit/forms/form_field.h" 26 #include "webkit/forms/form_field.h"
27 27
28 using content::BrowserThread; 28 using content::BrowserThread;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 246
247 bool autofill_enabled_; 247 bool autofill_enabled_;
248 bool did_finish_async_form_submit_; 248 bool did_finish_async_form_submit_;
249 bool message_loop_is_running_; 249 bool message_loop_is_running_;
250 250
251 DISALLOW_COPY_AND_ASSIGN(TestAutofillManager); 251 DISALLOW_COPY_AND_ASSIGN(TestAutofillManager);
252 }; 252 };
253 253
254 } // namespace 254 } // namespace
255 255
256 class AutofillMetricsTest : public TabContentsWrapperTestHarness { 256 class AutofillMetricsTest : public TabContentsTestHarness {
257 public: 257 public:
258 AutofillMetricsTest(); 258 AutofillMetricsTest();
259 virtual ~AutofillMetricsTest(); 259 virtual ~AutofillMetricsTest();
260 260
261 virtual void SetUp() OVERRIDE; 261 virtual void SetUp() OVERRIDE;
262 virtual void TearDown() OVERRIDE; 262 virtual void TearDown() OVERRIDE;
263 263
264 protected: 264 protected:
265 AutofillCCInfoBarDelegate* CreateDelegate(MockAutofillMetrics* metric_logger, 265 AutofillCCInfoBarDelegate* CreateDelegate(MockAutofillMetrics* metric_logger,
266 CreditCard** created_card); 266 CreditCard** created_card);
267 267
268 content::TestBrowserThread ui_thread_; 268 content::TestBrowserThread ui_thread_;
269 content::TestBrowserThread file_thread_; 269 content::TestBrowserThread file_thread_;
270 270
271 scoped_refptr<TestAutofillManager> autofill_manager_; 271 scoped_refptr<TestAutofillManager> autofill_manager_;
272 TestPersonalDataManager personal_data_; 272 TestPersonalDataManager personal_data_;
273 273
274 private: 274 private:
275 DISALLOW_COPY_AND_ASSIGN(AutofillMetricsTest); 275 DISALLOW_COPY_AND_ASSIGN(AutofillMetricsTest);
276 }; 276 };
277 277
278 AutofillMetricsTest::AutofillMetricsTest() 278 AutofillMetricsTest::AutofillMetricsTest()
279 : TabContentsWrapperTestHarness(), 279 : TabContentsTestHarness(),
280 ui_thread_(BrowserThread::UI, &message_loop_), 280 ui_thread_(BrowserThread::UI, &message_loop_),
281 file_thread_(BrowserThread::FILE) { 281 file_thread_(BrowserThread::FILE) {
282 } 282 }
283 283
284 AutofillMetricsTest::~AutofillMetricsTest() { 284 AutofillMetricsTest::~AutofillMetricsTest() {
285 // Order of destruction is important as AutofillManager relies on 285 // Order of destruction is important as AutofillManager relies on
286 // PersonalDataManager to be around when it gets destroyed. 286 // PersonalDataManager to be around when it gets destroyed.
287 autofill_manager_ = NULL; 287 autofill_manager_ = NULL;
288 } 288 }
289 289
290 void AutofillMetricsTest::SetUp() { 290 void AutofillMetricsTest::SetUp() {
291 Profile* profile = new TestingProfile(); 291 Profile* profile = new TestingProfile();
292 browser_context_.reset(profile); 292 browser_context_.reset(profile);
293 PersonalDataManagerFactory::GetInstance()->SetTestingFactory( 293 PersonalDataManagerFactory::GetInstance()->SetTestingFactory(
294 profile, NULL); 294 profile, NULL);
295 295
296 TabContentsWrapperTestHarness::SetUp(); 296 TabContentsTestHarness::SetUp();
297 autofill_manager_ = new TestAutofillManager(contents_wrapper(), 297 autofill_manager_ = new TestAutofillManager(tab_contents(),
298 &personal_data_); 298 &personal_data_);
299 299
300 file_thread_.Start(); 300 file_thread_.Start();
301 } 301 }
302 302
303 void AutofillMetricsTest::TearDown() { 303 void AutofillMetricsTest::TearDown() {
304 file_thread_.Stop(); 304 file_thread_.Stop();
305 TabContentsWrapperTestHarness::TearDown(); 305 TabContentsTestHarness::TearDown();
306 } 306 }
307 307
308 AutofillCCInfoBarDelegate* AutofillMetricsTest::CreateDelegate( 308 AutofillCCInfoBarDelegate* AutofillMetricsTest::CreateDelegate(
309 MockAutofillMetrics* metric_logger, 309 MockAutofillMetrics* metric_logger,
310 CreditCard** created_card) { 310 CreditCard** created_card) {
311 EXPECT_CALL(*metric_logger, 311 EXPECT_CALL(*metric_logger,
312 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); 312 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN));
313 // The delegate created below will take ownership of this object. 313 // The delegate created below will take ownership of this object.
314 CreditCard* credit_card = new CreditCard(); 314 CreditCard* credit_card = new CreditCard();
315 if (created_card) 315 if (created_card)
316 *created_card = credit_card; 316 *created_card = credit_card;
317 return new AutofillCCInfoBarDelegate(contents_wrapper()->infobar_tab_helper(), 317 return new AutofillCCInfoBarDelegate(tab_contents()->infobar_tab_helper(),
318 credit_card, 318 credit_card,
319 &personal_data_, 319 &personal_data_,
320 metric_logger); 320 metric_logger);
321 } 321 }
322 322
323 // Test that we log quality metrics appropriately. 323 // Test that we log quality metrics appropriately.
324 TEST_F(AutofillMetricsTest, QualityMetrics) { 324 TEST_F(AutofillMetricsTest, QualityMetrics) {
325 // Set up our form data. 325 // Set up our form data.
326 FormData form; 326 FormData form;
327 form.name = ASCIIToUTF16("TestForm"); 327 form.name = ASCIIToUTF16("TestForm");
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), 1460 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(),
1461 TimeTicks::FromInternalValue(3)); 1461 TimeTicks::FromInternalValue(3));
1462 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); 1462 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17));
1463 autofill_manager_->Reset(); 1463 autofill_manager_->Reset();
1464 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); 1464 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
1465 } 1465 }
1466 1466
1467 // Restore the global Gmock verbosity level to its default value. 1467 // Restore the global Gmock verbosity level to its default value.
1468 ::testing::FLAGS_gmock_verbose = "warning"; 1468 ::testing::FLAGS_gmock_verbose = "warning";
1469 } 1469 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager_unittest.cc ('k') | chrome/browser/automation/automation_tab_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698