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/bind.h" |
7 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
8 #include "base/string16.h" | 9 #include "base/string16.h" |
9 #include "base/time.h" | 10 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/autofill/autocheckout_infobar_delegate.h" | 12 #include "chrome/browser/autofill/autocheckout_infobar_delegate.h" |
12 #include "chrome/browser/autofill/autocheckout_page_meta_data.h" | 13 #include "chrome/browser/autofill/autocheckout_page_meta_data.h" |
13 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" | 14 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" |
14 #include "chrome/browser/autofill/autofill_common_test.h" | 15 #include "chrome/browser/autofill/autofill_common_test.h" |
15 #include "chrome/browser/autofill/autofill_manager.h" | 16 #include "chrome/browser/autofill/autofill_manager.h" |
16 #include "chrome/browser/autofill/autofill_manager_delegate.h" | 17 #include "chrome/browser/autofill/autofill_manager_delegate.h" |
17 #include "chrome/browser/autofill/autofill_metrics.h" | 18 #include "chrome/browser/autofill/autofill_metrics.h" |
18 #include "chrome/browser/autofill/personal_data_manager.h" | 19 #include "chrome/browser/autofill/personal_data_manager.h" |
19 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 20 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 21 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
20 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" | 22 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" |
21 #include "chrome/browser/webdata/web_data_service.h" | 23 #include "chrome/browser/webdata/web_data_service.h" |
22 #include "chrome/common/form_data.h" | 24 #include "chrome/common/form_data.h" |
23 #include "chrome/common/form_field_data.h" | 25 #include "chrome/common/form_field_data.h" |
24 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 26 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
25 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
26 #include "content/public/test/test_browser_thread.h" | 28 #include "content/public/test/test_browser_thread.h" |
27 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
30 #include "ui/gfx/rect.h" | 32 #include "ui/gfx/rect.h" |
31 | 33 |
32 using content::BrowserThread; | 34 using content::BrowserThread; |
33 using ::testing::_; | 35 using ::testing::_; |
34 using ::testing::AnyNumber; | 36 using ::testing::AnyNumber; |
35 using ::testing::Mock; | 37 using ::testing::Mock; |
36 using base::TimeTicks; | 38 using base::TimeTicks; |
37 using base::TimeDelta; | 39 using base::TimeDelta; |
38 | 40 |
39 namespace { | 41 namespace { |
40 | 42 |
41 class MockAutofillMetrics : public AutofillMetrics { | 43 class MockAutofillMetrics : public AutofillMetrics { |
42 public: | 44 public: |
43 MockAutofillMetrics() {} | 45 MockAutofillMetrics() {} |
44 MOCK_CONST_METHOD1(LogCreditCardInfoBarMetric, void(InfoBarMetric metric)); | 46 MOCK_CONST_METHOD1(LogCreditCardInfoBarMetric, void(InfoBarMetric metric)); |
45 MOCK_CONST_METHOD1(LogAutocheckoutInfoBarMetric, void(InfoBarMetric metric)); | 47 MOCK_CONST_METHOD1(LogAutocheckoutInfoBarMetric, void(InfoBarMetric metric)); |
| 48 MOCK_CONST_METHOD2(LogRequestAutocompleteUiDuration, |
| 49 void(const TimeDelta& duration, |
| 50 DialogDismissalAction dismissal_action)); |
46 MOCK_CONST_METHOD1(LogDeveloperEngagementMetric, | 51 MOCK_CONST_METHOD1(LogDeveloperEngagementMetric, |
47 void(DeveloperEngagementMetric metric)); | 52 void(DeveloperEngagementMetric metric)); |
48 MOCK_CONST_METHOD3(LogHeuristicTypePrediction, | 53 MOCK_CONST_METHOD3(LogHeuristicTypePrediction, |
49 void(FieldTypeQualityMetric metric, | 54 void(FieldTypeQualityMetric metric, |
50 AutofillFieldType field_type, | 55 AutofillFieldType field_type, |
51 const std::string& experiment_id)); | 56 const std::string& experiment_id)); |
52 MOCK_CONST_METHOD3(LogOverallTypePrediction, | 57 MOCK_CONST_METHOD3(LogOverallTypePrediction, |
53 void(FieldTypeQualityMetric metric, | 58 void(FieldTypeQualityMetric metric, |
54 AutofillFieldType field_type, | 59 AutofillFieldType field_type, |
55 const std::string& experiment_id)); | 60 const std::string& experiment_id)); |
(...skipping 26 matching lines...) Expand all Loading... |
82 DISALLOW_COPY_AND_ASSIGN(MockAutofillMetrics); | 87 DISALLOW_COPY_AND_ASSIGN(MockAutofillMetrics); |
83 }; | 88 }; |
84 | 89 |
85 class TestPersonalDataManager : public PersonalDataManager { | 90 class TestPersonalDataManager : public PersonalDataManager { |
86 public: | 91 public: |
87 TestPersonalDataManager() : autofill_enabled_(true) { | 92 TestPersonalDataManager() : autofill_enabled_(true) { |
88 set_metric_logger(new MockAutofillMetrics); | 93 set_metric_logger(new MockAutofillMetrics); |
89 CreateTestAutofillProfiles(&web_profiles_); | 94 CreateTestAutofillProfiles(&web_profiles_); |
90 } | 95 } |
91 | 96 |
| 97 static ProfileKeyedService* Build(Profile* profile) { |
| 98 return new TestPersonalDataManager(); |
| 99 } |
| 100 |
92 void SetBrowserContext(content::BrowserContext* context) { | 101 void SetBrowserContext(content::BrowserContext* context) { |
93 set_browser_context(context); | 102 set_browser_context(context); |
94 } | 103 } |
95 | 104 |
96 // Overridden to avoid a trip to the database. This should be a no-op except | 105 // Overridden to avoid a trip to the database. This should be a no-op except |
97 // for the side-effect of logging the profile count. | 106 // for the side-effect of logging the profile count. |
98 virtual void LoadProfiles() OVERRIDE { | 107 virtual void LoadProfiles() OVERRIDE { |
99 std::vector<AutofillProfile*> profiles; | 108 std::vector<AutofillProfile*> profiles; |
100 web_profiles_.release(&profiles); | 109 web_profiles_.release(&profiles); |
101 WDResult<std::vector<AutofillProfile*> > result(AUTOFILL_PROFILES_RESULT, | 110 WDResult<std::vector<AutofillProfile*> > result(AUTOFILL_PROFILES_RESULT, |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 // no-op. Just used as callback from autocheckout_infobar_delegate. | 282 // no-op. Just used as callback from autocheckout_infobar_delegate. |
274 } | 283 } |
275 | 284 |
276 virtual ~TestAutocheckoutManager() { | 285 virtual ~TestAutocheckoutManager() { |
277 } | 286 } |
278 | 287 |
279 private: | 288 private: |
280 DISALLOW_COPY_AND_ASSIGN(TestAutocheckoutManager); | 289 DISALLOW_COPY_AND_ASSIGN(TestAutocheckoutManager); |
281 }; | 290 }; |
282 | 291 |
| 292 void MockRequestAutocompleteDialogCallback(const FormStructure*) { |
| 293 } |
| 294 |
283 } // namespace | 295 } // namespace |
284 | 296 |
285 class AutofillMetricsTest : public ChromeRenderViewHostTestHarness { | 297 class AutofillMetricsTest : public ChromeRenderViewHostTestHarness { |
286 public: | 298 public: |
287 AutofillMetricsTest(); | 299 AutofillMetricsTest(); |
288 virtual ~AutofillMetricsTest(); | 300 virtual ~AutofillMetricsTest(); |
289 | 301 |
290 virtual void SetUp() OVERRIDE; | 302 virtual void SetUp() OVERRIDE; |
291 virtual void TearDown() OVERRIDE; | 303 virtual void TearDown() OVERRIDE; |
292 | 304 |
293 protected: | 305 protected: |
294 scoped_ptr<ConfirmInfoBarDelegate> CreateDelegate( | 306 scoped_ptr<ConfirmInfoBarDelegate> CreateDelegate( |
295 MockAutofillMetrics* metric_logger, | 307 MockAutofillMetrics* metric_logger, |
296 CreditCard** created_card); | 308 CreditCard** created_card); |
297 | 309 |
298 scoped_ptr<ConfirmInfoBarDelegate> CreateAutocheckoutDelegate( | 310 scoped_ptr<ConfirmInfoBarDelegate> CreateAutocheckoutDelegate( |
299 MockAutofillMetrics* metric_logger); | 311 MockAutofillMetrics* metric_logger); |
300 | 312 |
301 content::TestBrowserThread ui_thread_; | 313 content::TestBrowserThread ui_thread_; |
302 content::TestBrowserThread file_thread_; | 314 content::TestBrowserThread file_thread_; |
| 315 content::TestBrowserThread io_thread_; |
303 | 316 |
304 scoped_refptr<TestAutofillManager> autofill_manager_; | 317 scoped_refptr<TestAutofillManager> autofill_manager_; |
305 TestAutocheckoutManager autocheckout_manager_; | 318 TestAutocheckoutManager autocheckout_manager_; |
306 TestPersonalDataManager personal_data_; | 319 TestPersonalDataManager* personal_data_; |
307 | 320 |
308 private: | 321 private: |
309 std::string default_gmock_verbosity_level_; | 322 std::string default_gmock_verbosity_level_; |
310 | 323 |
311 DISALLOW_COPY_AND_ASSIGN(AutofillMetricsTest); | 324 DISALLOW_COPY_AND_ASSIGN(AutofillMetricsTest); |
312 }; | 325 }; |
313 | 326 |
314 AutofillMetricsTest::AutofillMetricsTest() | 327 AutofillMetricsTest::AutofillMetricsTest() |
315 : ChromeRenderViewHostTestHarness(), | 328 : ChromeRenderViewHostTestHarness(), |
316 ui_thread_(BrowserThread::UI, &message_loop_), | 329 ui_thread_(BrowserThread::UI, &message_loop_), |
317 file_thread_(BrowserThread::FILE), | 330 file_thread_(BrowserThread::FILE), |
| 331 io_thread_(BrowserThread::IO), |
318 autocheckout_manager_(NULL) { | 332 autocheckout_manager_(NULL) { |
319 } | 333 } |
320 | 334 |
321 AutofillMetricsTest::~AutofillMetricsTest() { | 335 AutofillMetricsTest::~AutofillMetricsTest() { |
322 // Order of destruction is important as AutofillManager relies on | 336 // Order of destruction is important as AutofillManager relies on |
323 // PersonalDataManager to be around when it gets destroyed. | 337 // PersonalDataManager to be around when it gets destroyed. |
324 autofill_manager_ = NULL; | 338 autofill_manager_ = NULL; |
325 } | 339 } |
326 | 340 |
327 void AutofillMetricsTest::SetUp() { | 341 void AutofillMetricsTest::SetUp() { |
328 Profile* profile = new TestingProfile(); | 342 TestingProfile* profile = new TestingProfile(); |
| 343 profile->CreateRequestContext(); |
329 browser_context_.reset(profile); | 344 browser_context_.reset(profile); |
330 PersonalDataManagerFactory::GetInstance()->SetTestingFactory(profile, NULL); | 345 personal_data_ = |
| 346 static_cast<TestPersonalDataManager*>( |
| 347 PersonalDataManagerFactory::GetInstance()->SetTestingFactoryAndUse( |
| 348 profile, TestPersonalDataManager::Build)); |
331 | 349 |
332 ChromeRenderViewHostTestHarness::SetUp(); | 350 ChromeRenderViewHostTestHarness::SetUp(); |
| 351 io_thread_.StartIOThread(); |
| 352 |
333 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); | 353 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); |
334 personal_data_.SetBrowserContext(profile); | 354 personal_data_->SetBrowserContext(profile); |
335 autofill_manager_ = new TestAutofillManager( | 355 autofill_manager_ = new TestAutofillManager( |
336 web_contents(), | 356 web_contents(), |
337 TabAutofillManagerDelegate::FromWebContents(web_contents()), | 357 TabAutofillManagerDelegate::FromWebContents(web_contents()), |
338 &personal_data_); | 358 personal_data_); |
339 | 359 |
340 file_thread_.Start(); | 360 file_thread_.Start(); |
341 | 361 |
342 // Ignore any metrics that we haven't explicitly set expectations for. | 362 // 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 | 363 // 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 | 364 // mocked functions that aren't relevant to a test but happen to be called |
345 // during the test's execution. | 365 // during the test's execution. |
346 // CAUTION: This is a global variable. So as to not affect other tests, this | 366 // 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. | 367 // _must_ be restored to its original value at the end of the test. |
348 default_gmock_verbosity_level_ = ::testing::FLAGS_gmock_verbose; | 368 default_gmock_verbosity_level_ = ::testing::FLAGS_gmock_verbose; |
349 ::testing::FLAGS_gmock_verbose = "error"; | 369 ::testing::FLAGS_gmock_verbose = "error"; |
350 } | 370 } |
351 | 371 |
352 void AutofillMetricsTest::TearDown() { | 372 void AutofillMetricsTest::TearDown() { |
353 // Restore the global Gmock verbosity level to its default value. | 373 // Restore the global Gmock verbosity level to its default value. |
354 ::testing::FLAGS_gmock_verbose = default_gmock_verbosity_level_; | 374 ::testing::FLAGS_gmock_verbose = default_gmock_verbosity_level_; |
355 | 375 |
356 // Order of destruction is important as AutofillManager relies on | 376 // Order of destruction is important as AutofillManager relies on |
357 // PersonalDataManager to be around when it gets destroyed. Also, a real | 377 // PersonalDataManager to be around when it gets destroyed. Also, a real |
358 // AutofillManager is tied to the lifetime of the WebContents, so it must | 378 // AutofillManager is tied to the lifetime of the WebContents, so it must |
359 // be destroyed at the destruction of the WebContents. | 379 // be destroyed at the destruction of the WebContents. |
360 autofill_manager_ = NULL; | 380 autofill_manager_ = NULL; |
361 file_thread_.Stop(); | 381 file_thread_.Stop(); |
| 382 |
| 383 profile()->ResetRequestContext(); |
362 ChromeRenderViewHostTestHarness::TearDown(); | 384 ChromeRenderViewHostTestHarness::TearDown(); |
| 385 io_thread_.Stop(); |
363 } | 386 } |
364 | 387 |
365 scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate( | 388 scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate( |
366 MockAutofillMetrics* metric_logger, | 389 MockAutofillMetrics* metric_logger, |
367 CreditCard** created_card) { | 390 CreditCard** created_card) { |
368 EXPECT_CALL(*metric_logger, | 391 EXPECT_CALL(*metric_logger, |
369 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); | 392 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); |
370 // The delegate created below will take ownership of this object. | 393 // The delegate created below will take ownership of this object. |
371 CreditCard* credit_card = new CreditCard(); | 394 CreditCard* credit_card = new CreditCard(); |
372 if (created_card) | 395 if (created_card) |
373 *created_card = credit_card; | 396 *created_card = credit_card; |
374 return AutofillCCInfoBarDelegate::Create(credit_card, &personal_data_, | 397 return AutofillCCInfoBarDelegate::Create(credit_card, personal_data_, |
375 metric_logger); | 398 metric_logger); |
376 } | 399 } |
377 | 400 |
378 scoped_ptr<ConfirmInfoBarDelegate> | 401 scoped_ptr<ConfirmInfoBarDelegate> |
379 AutofillMetricsTest::CreateAutocheckoutDelegate( | 402 AutofillMetricsTest::CreateAutocheckoutDelegate( |
380 MockAutofillMetrics* metric_logger) { | 403 MockAutofillMetrics* metric_logger) { |
381 EXPECT_CALL(*metric_logger, | 404 EXPECT_CALL(*metric_logger, |
382 LogAutocheckoutInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); | 405 LogAutocheckoutInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); |
383 GURL url("www.google.com"); | 406 GURL url("www.google.com"); |
384 content::SSLStatus ssl_status; | 407 content::SSLStatus ssl_status; |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 ADDRESS_HOME_COUNTRY, experiment_id)); | 1076 ADDRESS_HOME_COUNTRY, experiment_id)); |
1054 | 1077 |
1055 // Simulate form submission. | 1078 // Simulate form submission. |
1056 EXPECT_NO_FATAL_FAILURE(autofill_manager_->FormSubmitted(form, | 1079 EXPECT_NO_FATAL_FAILURE(autofill_manager_->FormSubmitted(form, |
1057 TimeTicks::Now())); | 1080 TimeTicks::Now())); |
1058 } | 1081 } |
1059 | 1082 |
1060 // Test that the profile count is logged correctly. | 1083 // Test that the profile count is logged correctly. |
1061 TEST_F(AutofillMetricsTest, StoredProfileCount) { | 1084 TEST_F(AutofillMetricsTest, StoredProfileCount) { |
1062 // The metric should be logged when the profiles are first loaded. | 1085 // The metric should be logged when the profiles are first loaded. |
1063 EXPECT_CALL(*personal_data_.metric_logger(), | 1086 EXPECT_CALL(*personal_data_->metric_logger(), |
1064 LogStoredProfileCount(2)).Times(1); | 1087 LogStoredProfileCount(2)).Times(1); |
1065 personal_data_.LoadProfiles(); | 1088 personal_data_->LoadProfiles(); |
1066 | 1089 |
1067 // The metric should only be logged once. | 1090 // The metric should only be logged once. |
1068 EXPECT_CALL(*personal_data_.metric_logger(), | 1091 EXPECT_CALL(*personal_data_->metric_logger(), |
1069 LogStoredProfileCount(::testing::_)).Times(0); | 1092 LogStoredProfileCount(::testing::_)).Times(0); |
1070 personal_data_.LoadProfiles(); | 1093 personal_data_->LoadProfiles(); |
1071 } | 1094 } |
1072 | 1095 |
1073 // Test that we correctly log whether Autofill is enabled. | 1096 // Test that we correctly log whether Autofill is enabled. |
1074 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtStartup) { | 1097 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtStartup) { |
1075 personal_data_.set_autofill_enabled(true); | 1098 personal_data_->set_autofill_enabled(true); |
1076 EXPECT_CALL(*personal_data_.metric_logger(), | 1099 EXPECT_CALL(*personal_data_->metric_logger(), |
1077 LogIsAutofillEnabledAtStartup(true)).Times(1); | 1100 LogIsAutofillEnabledAtStartup(true)).Times(1); |
1078 personal_data_.Init(profile()); | 1101 personal_data_->Init(profile()); |
1079 personal_data_.Shutdown(); | 1102 personal_data_->Shutdown(); |
1080 | 1103 |
1081 personal_data_.set_autofill_enabled(false); | 1104 personal_data_->set_autofill_enabled(false); |
1082 EXPECT_CALL(*personal_data_.metric_logger(), | 1105 EXPECT_CALL(*personal_data_->metric_logger(), |
1083 LogIsAutofillEnabledAtStartup(false)).Times(1); | 1106 LogIsAutofillEnabledAtStartup(false)).Times(1); |
1084 personal_data_.Init(profile()); | 1107 personal_data_->Init(profile()); |
1085 } | 1108 } |
1086 | 1109 |
1087 // Test that we log the number of Autofill suggestions when filling a form. | 1110 // Test that we log the number of Autofill suggestions when filling a form. |
1088 TEST_F(AutofillMetricsTest, AddressSuggestionsCount) { | 1111 TEST_F(AutofillMetricsTest, AddressSuggestionsCount) { |
1089 // Set up our form data. | 1112 // Set up our form data. |
1090 FormData form; | 1113 FormData form; |
1091 form.name = ASCIIToUTF16("TestForm"); | 1114 form.name = ASCIIToUTF16("TestForm"); |
1092 form.method = ASCIIToUTF16("POST"); | 1115 form.method = ASCIIToUTF16("POST"); |
1093 form.origin = GURL("http://example.com/form.html"); | 1116 form.origin = GURL("http://example.com/form.html"); |
1094 form.action = GURL("http://example.com/submit.html"); | 1117 form.action = GURL("http://example.com/submit.html"); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 TEST_F(AutofillMetricsTest, CreditCardInfoBar) { | 1202 TEST_F(AutofillMetricsTest, CreditCardInfoBar) { |
1180 MockAutofillMetrics metric_logger; | 1203 MockAutofillMetrics metric_logger; |
1181 ::testing::InSequence dummy; | 1204 ::testing::InSequence dummy; |
1182 | 1205 |
1183 // Accept the infobar. | 1206 // Accept the infobar. |
1184 { | 1207 { |
1185 CreditCard* credit_card; | 1208 CreditCard* credit_card; |
1186 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate(&metric_logger, | 1209 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate(&metric_logger, |
1187 &credit_card)); | 1210 &credit_card)); |
1188 ASSERT_TRUE(infobar); | 1211 ASSERT_TRUE(infobar); |
1189 EXPECT_CALL(personal_data_, SaveImportedCreditCard(*credit_card)); | 1212 EXPECT_CALL(*personal_data_, SaveImportedCreditCard(*credit_card)); |
1190 EXPECT_CALL(metric_logger, | 1213 EXPECT_CALL(metric_logger, |
1191 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_ACCEPTED)).Times(1); | 1214 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_ACCEPTED)).Times(1); |
1192 EXPECT_CALL(metric_logger, | 1215 EXPECT_CALL(metric_logger, |
1193 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)).Times(0); | 1216 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)).Times(0); |
1194 EXPECT_TRUE(infobar->Accept()); | 1217 EXPECT_TRUE(infobar->Accept()); |
1195 } | 1218 } |
1196 | 1219 |
1197 // Cancel the infobar. | 1220 // Cancel the infobar. |
1198 { | 1221 { |
1199 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate(&metric_logger, | 1222 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate(&metric_logger, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 { | 1302 { |
1280 scoped_ptr<ConfirmInfoBarDelegate> infobar( | 1303 scoped_ptr<ConfirmInfoBarDelegate> infobar( |
1281 CreateAutocheckoutDelegate(&metric_logger)); | 1304 CreateAutocheckoutDelegate(&metric_logger)); |
1282 ASSERT_TRUE(infobar); | 1305 ASSERT_TRUE(infobar); |
1283 EXPECT_CALL(metric_logger, | 1306 EXPECT_CALL(metric_logger, |
1284 LogAutocheckoutInfoBarMetric( | 1307 LogAutocheckoutInfoBarMetric( |
1285 AutofillMetrics::INFOBAR_IGNORED)).Times(1); | 1308 AutofillMetrics::INFOBAR_IGNORED)).Times(1); |
1286 } | 1309 } |
1287 } | 1310 } |
1288 | 1311 |
| 1312 // TODO(isherman): Enable this test on other platforms once the UI is |
| 1313 // implemented on those platforms. |
| 1314 #if defined(TOOLKIT_VIEWS) |
| 1315 TEST_F(AutofillMetricsTest, RequestAutocompleteUiDuration) { |
| 1316 MockAutofillMetrics metric_logger; |
| 1317 ::testing::InSequence dummy; |
| 1318 |
| 1319 FormData form; |
| 1320 form.name = ASCIIToUTF16("TestForm"); |
| 1321 form.method = ASCIIToUTF16("POST"); |
| 1322 form.origin = GURL("http://example.com/form.html"); |
| 1323 form.action = GURL("http://example.com/submit.html"); |
| 1324 form.user_submitted = true; |
| 1325 |
| 1326 FormFieldData field; |
| 1327 field.autocomplete_attribute = "email"; |
| 1328 form.fields.push_back(field); |
| 1329 |
| 1330 // Submit the form data. |
| 1331 { |
| 1332 EXPECT_CALL(metric_logger, |
| 1333 LogRequestAutocompleteUiDuration( |
| 1334 _, AutofillMetrics::DIALOG_ACCEPTED)).Times(1); |
| 1335 |
| 1336 autofill::AutofillDialogControllerImpl* dialog_controller = |
| 1337 new autofill::AutofillDialogControllerImpl( |
| 1338 web_contents(), form, GURL(), content::SSLStatus(), |
| 1339 metric_logger, base::Bind(&MockRequestAutocompleteDialogCallback)); |
| 1340 dialog_controller->Show(); |
| 1341 dialog_controller->ViewClosed(autofill::ACTION_SUBMIT); |
| 1342 } |
| 1343 |
| 1344 // Cancel out of the dialog. |
| 1345 { |
| 1346 EXPECT_CALL(metric_logger, |
| 1347 LogRequestAutocompleteUiDuration( |
| 1348 _, AutofillMetrics::DIALOG_CANCELED)).Times(1); |
| 1349 |
| 1350 autofill::AutofillDialogControllerImpl* dialog_controller = |
| 1351 new autofill::AutofillDialogControllerImpl( |
| 1352 web_contents(), form, GURL(), content::SSLStatus(), |
| 1353 metric_logger, base::Bind(&MockRequestAutocompleteDialogCallback)); |
| 1354 dialog_controller->Show(); |
| 1355 dialog_controller->ViewClosed(autofill::ACTION_ABORT); |
| 1356 } |
| 1357 |
| 1358 // Take some other action that dismisses the dialog. |
| 1359 { |
| 1360 EXPECT_CALL(metric_logger, |
| 1361 LogRequestAutocompleteUiDuration( |
| 1362 _, AutofillMetrics::DIALOG_CANCELED)).Times(1); |
| 1363 |
| 1364 autofill::AutofillDialogControllerImpl* dialog_controller = |
| 1365 new autofill::AutofillDialogControllerImpl( |
| 1366 web_contents(), form, GURL(), content::SSLStatus(), |
| 1367 metric_logger, base::Bind(&MockRequestAutocompleteDialogCallback)); |
| 1368 dialog_controller->Show(); |
| 1369 dialog_controller->Hide(); |
| 1370 } |
| 1371 } |
| 1372 #endif // defined(TOOLKIT_VIEWS) |
1289 | 1373 |
1290 // Test that server query response experiment id metrics are logged correctly. | 1374 // Test that server query response experiment id metrics are logged correctly. |
1291 TEST_F(AutofillMetricsTest, ServerQueryExperimentIdForQuery) { | 1375 TEST_F(AutofillMetricsTest, ServerQueryExperimentIdForQuery) { |
1292 MockAutofillMetrics metric_logger; | 1376 MockAutofillMetrics metric_logger; |
1293 ::testing::InSequence dummy; | 1377 ::testing::InSequence dummy; |
1294 | 1378 |
1295 // No experiment specified. | 1379 // No experiment specified. |
1296 EXPECT_CALL(metric_logger, | 1380 EXPECT_CALL(metric_logger, |
1297 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED)); | 1381 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED)); |
1298 EXPECT_CALL(metric_logger, | 1382 EXPECT_CALL(metric_logger, |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | 1752 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); |
1669 autofill_manager_->OnDidFillAutofillFormData( | 1753 autofill_manager_->OnDidFillAutofillFormData( |
1670 TimeTicks::FromInternalValue(5)); | 1754 TimeTicks::FromInternalValue(5)); |
1671 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 1755 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
1672 TimeTicks::FromInternalValue(3)); | 1756 TimeTicks::FromInternalValue(3)); |
1673 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 1757 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
1674 autofill_manager_->Reset(); | 1758 autofill_manager_->Reset(); |
1675 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1759 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
1676 } | 1760 } |
1677 } | 1761 } |
OLD | NEW |