| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "content/public/browser/render_widget_host.h" | 46 #include "content/public/browser/render_widget_host.h" |
| 47 #include "content/public/browser/web_contents.h" | 47 #include "content/public/browser/web_contents.h" |
| 48 #include "content/public/test/browser_test_utils.h" | 48 #include "content/public/test/browser_test_utils.h" |
| 49 #include "content/public/test/test_renderer_host.h" | 49 #include "content/public/test/test_renderer_host.h" |
| 50 #include "content/public/test/test_utils.h" | 50 #include "content/public/test/test_utils.h" |
| 51 #include "net/url_request/test_url_fetcher_factory.h" | 51 #include "net/url_request/test_url_fetcher_factory.h" |
| 52 #include "testing/gmock/include/gmock/gmock.h" | 52 #include "testing/gmock/include/gmock/gmock.h" |
| 53 #include "testing/gtest/include/gtest/gtest.h" | 53 #include "testing/gtest/include/gtest/gtest.h" |
| 54 #include "ui/events/keycodes/keyboard_codes.h" | 54 #include "ui/events/keycodes/keyboard_codes.h" |
| 55 | 55 |
| 56 using base::ASCIIToUTF16; |
| 56 | 57 |
| 57 namespace autofill { | 58 namespace autofill { |
| 58 | 59 |
| 59 static const char* kDataURIPrefix = "data:text/html;charset=utf-8,"; | 60 static const char* kDataURIPrefix = "data:text/html;charset=utf-8,"; |
| 60 static const char* kTestFormString = | 61 static const char* kTestFormString = |
| 61 "<form action=\"http://www.example.com/\" method=\"POST\">" | 62 "<form action=\"http://www.example.com/\" method=\"POST\">" |
| 62 "<label for=\"firstname\">First name:</label>" | 63 "<label for=\"firstname\">First name:</label>" |
| 63 " <input type=\"text\" id=\"firstname\"" | 64 " <input type=\"text\" id=\"firstname\"" |
| 64 " onFocus=\"domAutomationController.send(true)\"><br>" | 65 " onFocus=\"domAutomationController.send(true)\"><br>" |
| 65 "<label for=\"lastname\">Last name:</label>" | 66 "<label for=\"lastname\">Last name:</label>" |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 const int kNumProfiles = 1500; | 1025 const int kNumProfiles = 1500; |
| 1025 base::Time start_time = base::Time::Now(); | 1026 base::Time start_time = base::Time::Now(); |
| 1026 std::vector<AutofillProfile> profiles; | 1027 std::vector<AutofillProfile> profiles; |
| 1027 for (int i = 0; i < kNumProfiles; i++) { | 1028 for (int i = 0; i < kNumProfiles; i++) { |
| 1028 AutofillProfile profile; | 1029 AutofillProfile profile; |
| 1029 base::string16 name(base::IntToString16(i)); | 1030 base::string16 name(base::IntToString16(i)); |
| 1030 base::string16 email(name + ASCIIToUTF16("@example.com")); | 1031 base::string16 email(name + ASCIIToUTF16("@example.com")); |
| 1031 base::string16 street = ASCIIToUTF16( | 1032 base::string16 street = ASCIIToUTF16( |
| 1032 base::IntToString(base::RandInt(0, 10000)) + " " + | 1033 base::IntToString(base::RandInt(0, 10000)) + " " + |
| 1033 streets[base::RandInt(0, streets.size() - 1)]); | 1034 streets[base::RandInt(0, streets.size() - 1)]); |
| 1034 base::string16 city = ASCIIToUTF16(cities[base::RandInt(0, cities.size() - 1
)]); | 1035 base::string16 city = |
| 1036 ASCIIToUTF16(cities[base::RandInt(0, cities.size() - 1)]); |
| 1035 base::string16 zip(base::IntToString16(base::RandInt(0, 10000))); | 1037 base::string16 zip(base::IntToString16(base::RandInt(0, 10000))); |
| 1036 profile.SetRawInfo(NAME_FIRST, name); | 1038 profile.SetRawInfo(NAME_FIRST, name); |
| 1037 profile.SetRawInfo(EMAIL_ADDRESS, email); | 1039 profile.SetRawInfo(EMAIL_ADDRESS, email); |
| 1038 profile.SetRawInfo(ADDRESS_HOME_LINE1, street); | 1040 profile.SetRawInfo(ADDRESS_HOME_LINE1, street); |
| 1039 profile.SetRawInfo(ADDRESS_HOME_CITY, city); | 1041 profile.SetRawInfo(ADDRESS_HOME_CITY, city); |
| 1040 profile.SetRawInfo(ADDRESS_HOME_STATE, WideToUTF16(L"CA")); | 1042 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); |
| 1041 profile.SetRawInfo(ADDRESS_HOME_ZIP, zip); | 1043 profile.SetRawInfo(ADDRESS_HOME_ZIP, zip); |
| 1042 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, WideToUTF16(L"US")); | 1044 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); |
| 1043 profiles.push_back(profile); | 1045 profiles.push_back(profile); |
| 1044 } | 1046 } |
| 1045 SetProfiles(&profiles); | 1047 SetProfiles(&profiles); |
| 1046 // TODO(isherman): once we're sure this test doesn't timeout on any bots, this | 1048 // TODO(isherman): once we're sure this test doesn't timeout on any bots, this |
| 1047 // can be removd. | 1049 // can be removd. |
| 1048 LOG(INFO) << "Created " << kNumProfiles << " profiles in " << | 1050 LOG(INFO) << "Created " << kNumProfiles << " profiles in " << |
| 1049 (base::Time::Now() - start_time).InSeconds() << " seconds."; | 1051 (base::Time::Now() - start_time).InSeconds() << " seconds."; |
| 1050 | 1052 |
| 1051 GURL url = test_server()->GetURL( | 1053 GURL url = test_server()->GetURL( |
| 1052 "files/autofill/latency_after_submit_test.html"); | 1054 "files/autofill/latency_after_submit_test.html"); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 ASSERT_TRUE(content::ExecuteScript( | 1088 ASSERT_TRUE(content::ExecuteScript( |
| 1087 GetRenderViewHost(), | 1089 GetRenderViewHost(), |
| 1088 "document.querySelector('input').autocomplete = 'off';")); | 1090 "document.querySelector('input').autocomplete = 'off';")); |
| 1089 | 1091 |
| 1090 // Press the down arrow to select the suggestion and attempt to preview the | 1092 // Press the down arrow to select the suggestion and attempt to preview the |
| 1091 // autofilled form. | 1093 // autofilled form. |
| 1092 SendKeyToPopupAndWait(ui::VKEY_DOWN); | 1094 SendKeyToPopupAndWait(ui::VKEY_DOWN); |
| 1093 } | 1095 } |
| 1094 | 1096 |
| 1095 } // namespace autofill | 1097 } // namespace autofill |
| OLD | NEW |