OLD | NEW |
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" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // AutofillManager is ref counted. | 254 // AutofillManager is ref counted. |
255 virtual ~TestAutofillManager() {} | 255 virtual ~TestAutofillManager() {} |
256 | 256 |
257 bool autofill_enabled_; | 257 bool autofill_enabled_; |
258 bool did_finish_async_form_submit_; | 258 bool did_finish_async_form_submit_; |
259 bool message_loop_is_running_; | 259 bool message_loop_is_running_; |
260 | 260 |
261 DISALLOW_COPY_AND_ASSIGN(TestAutofillManager); | 261 DISALLOW_COPY_AND_ASSIGN(TestAutofillManager); |
262 }; | 262 }; |
263 | 263 |
264 class TestAutocheckoutManager : public AutocheckoutManager { | 264 class TestAutocheckoutManager : public autofill::AutocheckoutManager { |
265 public: | 265 public: |
266 explicit TestAutocheckoutManager(AutofillManager* autofill_manager) | 266 explicit TestAutocheckoutManager(AutofillManager* autofill_manager) |
267 : AutocheckoutManager(autofill_manager) { | 267 : AutocheckoutManager(autofill_manager) { |
268 } | 268 } |
269 | 269 |
270 virtual void ShowAutocheckoutDialog( | 270 virtual void ShowAutocheckoutDialog( |
271 const GURL& frame_url, | 271 const GURL& frame_url, |
272 const content::SSLStatus& ssl_status) OVERRIDE { | 272 const content::SSLStatus& ssl_status) OVERRIDE { |
273 // no-op. Just used as callback from autocheckout_infobar_delegate. | 273 // no-op. Just used as callback from autocheckout_infobar_delegate. |
274 } | 274 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 // PersonalDataManager to be around when it gets destroyed. | 323 // PersonalDataManager to be around when it gets destroyed. |
324 autofill_manager_ = NULL; | 324 autofill_manager_ = NULL; |
325 } | 325 } |
326 | 326 |
327 void AutofillMetricsTest::SetUp() { | 327 void AutofillMetricsTest::SetUp() { |
328 Profile* profile = new TestingProfile(); | 328 Profile* profile = new TestingProfile(); |
329 browser_context_.reset(profile); | 329 browser_context_.reset(profile); |
330 PersonalDataManagerFactory::GetInstance()->SetTestingFactory(profile, NULL); | 330 PersonalDataManagerFactory::GetInstance()->SetTestingFactory(profile, NULL); |
331 | 331 |
332 ChromeRenderViewHostTestHarness::SetUp(); | 332 ChromeRenderViewHostTestHarness::SetUp(); |
333 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); | 333 autofill::TabAutofillManagerDelegate::CreateForWebContents(web_contents()); |
334 personal_data_.SetBrowserContext(profile); | 334 personal_data_.SetBrowserContext(profile); |
335 autofill_manager_ = new TestAutofillManager( | 335 autofill_manager_ = new TestAutofillManager( |
336 web_contents(), | 336 web_contents(), |
337 TabAutofillManagerDelegate::FromWebContents(web_contents()), | 337 autofill::TabAutofillManagerDelegate::FromWebContents(web_contents()), |
338 &personal_data_); | 338 &personal_data_); |
339 | 339 |
340 file_thread_.Start(); | 340 file_thread_.Start(); |
341 | 341 |
342 // Ignore any metrics that we haven't explicitly set expectations for. | 342 // Ignore any metrics that we haven't explicitly set expectations for. |
343 // If we don't override the verbosity level, we'll get lots of log spew from | 343 // If we don't override the verbosity level, we'll get lots of log spew from |
344 // mocked functions that aren't relevant to a test but happen to be called | 344 // mocked functions that aren't relevant to a test but happen to be called |
345 // during the test's execution. | 345 // during the test's execution. |
346 // CAUTION: This is a global variable. So as to not affect other tests, this | 346 // CAUTION: This is a global variable. So as to not affect other tests, this |
347 // _must_ be restored to its original value at the end of the test. | 347 // _must_ be restored to its original value at the end of the test. |
(...skipping 27 matching lines...) Expand all Loading... |
375 metric_logger); | 375 metric_logger); |
376 } | 376 } |
377 | 377 |
378 scoped_ptr<ConfirmInfoBarDelegate> | 378 scoped_ptr<ConfirmInfoBarDelegate> |
379 AutofillMetricsTest::CreateAutocheckoutDelegate( | 379 AutofillMetricsTest::CreateAutocheckoutDelegate( |
380 MockAutofillMetrics* metric_logger) { | 380 MockAutofillMetrics* metric_logger) { |
381 EXPECT_CALL(*metric_logger, | 381 EXPECT_CALL(*metric_logger, |
382 LogAutocheckoutInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); | 382 LogAutocheckoutInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); |
383 GURL url("www.google.com"); | 383 GURL url("www.google.com"); |
384 content::SSLStatus ssl_status; | 384 content::SSLStatus ssl_status; |
385 return AutocheckoutInfoBarDelegate::Create( | 385 return autofill::AutocheckoutInfoBarDelegate::Create( |
386 *metric_logger, | 386 *metric_logger, |
387 url, | 387 url, |
388 ssl_status, | 388 ssl_status, |
389 &autocheckout_manager_); | 389 &autocheckout_manager_); |
390 } | 390 } |
391 | 391 |
392 // Test that we log quality metrics appropriately. | 392 // Test that we log quality metrics appropriately. |
393 TEST_F(AutofillMetricsTest, QualityMetrics) { | 393 TEST_F(AutofillMetricsTest, QualityMetrics) { |
394 // Set up our form data. | 394 // Set up our form data. |
395 FormData form; | 395 FormData form; |
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | 1668 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); |
1669 autofill_manager_->OnDidFillAutofillFormData( | 1669 autofill_manager_->OnDidFillAutofillFormData( |
1670 TimeTicks::FromInternalValue(5)); | 1670 TimeTicks::FromInternalValue(5)); |
1671 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 1671 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
1672 TimeTicks::FromInternalValue(3)); | 1672 TimeTicks::FromInternalValue(3)); |
1673 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 1673 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
1674 autofill_manager_->Reset(); | 1674 autofill_manager_->Reset(); |
1675 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1675 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
1676 } | 1676 } |
1677 } | 1677 } |
OLD | NEW |