| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 db_thread_.Stop(); | 99 db_thread_.Stop(); |
| 100 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); | 100 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); |
| 101 MessageLoop::current()->Run(); | 101 MessageLoop::current()->Run(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void AppendFormField(const string16& name, | 104 void AppendFormField(const string16& name, |
| 105 const string16& value, | 105 const string16& value, |
| 106 std::vector<webkit_glue::FormField>* form_fields) { | 106 std::vector<webkit_glue::FormField>* form_fields) { |
| 107 form_fields->push_back( | 107 form_fields->push_back( |
| 108 webkit_glue::FormField(EmptyString16(), | 108 webkit_glue::FormField(string16(), name, string16(), value)); |
| 109 name, | |
| 110 EmptyString16(), | |
| 111 value)); | |
| 112 } | 109 } |
| 113 | 110 |
| 114 MessageLoopForUI message_loop_; | 111 MessageLoopForUI message_loop_; |
| 115 ChromeThread ui_thread_; | 112 ChromeThread ui_thread_; |
| 116 ChromeThread db_thread_; | 113 ChromeThread db_thread_; |
| 117 string16 name1_; | 114 string16 name1_; |
| 118 string16 name2_; | 115 string16 name2_; |
| 119 string16 value1_; | 116 string16 value1_; |
| 120 string16 value2_; | 117 string16 value2_; |
| 121 FilePath profile_dir_; | 118 FilePath profile_dir_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 149 AppendFormField(name2_, value2_, &form_fields); | 146 AppendFormField(name2_, value2_, &form_fields); |
| 150 wds_->AddFormFieldValues(form_fields); | 147 wds_->AddFormFieldValues(form_fields); |
| 151 | 148 |
| 152 // The message loop will exit when the mock observer is notified. | 149 // The message loop will exit when the mock observer is notified. |
| 153 MessageLoop::current()->Run(); | 150 MessageLoop::current()->Run(); |
| 154 | 151 |
| 155 AutofillWebDataServiceConsumer consumer; | 152 AutofillWebDataServiceConsumer consumer; |
| 156 WebDataService::Handle handle; | 153 WebDataService::Handle handle; |
| 157 static const int limit = 10; | 154 static const int limit = 10; |
| 158 handle = wds_->GetFormValuesForElementName( | 155 handle = wds_->GetFormValuesForElementName( |
| 159 name1_, EmptyString16(), limit, &consumer); | 156 name1_, string16(), limit, &consumer); |
| 160 | 157 |
| 161 // The message loop will exit when the consumer is called. | 158 // The message loop will exit when the consumer is called. |
| 162 MessageLoop::current()->Run(); | 159 MessageLoop::current()->Run(); |
| 163 | 160 |
| 164 EXPECT_EQ(handle, consumer.handle()); | 161 EXPECT_EQ(handle, consumer.handle()); |
| 165 ASSERT_EQ(1U, consumer.values().size()); | 162 ASSERT_EQ(1U, consumer.values().size()); |
| 166 EXPECT_EQ(value1_, consumer.values()[0]); | 163 EXPECT_EQ(value1_, consumer.values()[0]); |
| 167 } | 164 } |
| 168 | 165 |
| 169 TEST_F(WebDataServiceTest, AutofillRemoveOne) { | 166 TEST_F(WebDataServiceTest, AutofillRemoveOne) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 Observe(NotificationType(NotificationType::AUTOFILL_ENTRIES_CHANGED), | 221 Observe(NotificationType(NotificationType::AUTOFILL_ENTRIES_CHANGED), |
| 225 NotificationService::AllSources(), | 222 NotificationService::AllSources(), |
| 226 Property(&Details<const AutofillChangeList>::ptr, | 223 Property(&Details<const AutofillChangeList>::ptr, |
| 227 Pointee(ElementsAreArray(expected_changes))))). | 224 Pointee(ElementsAreArray(expected_changes))))). |
| 228 WillOnce(QuitUIMessageLoop()); | 225 WillOnce(QuitUIMessageLoop()); |
| 229 wds_->RemoveFormElementsAddedBetween(t, t + one_day); | 226 wds_->RemoveFormElementsAddedBetween(t, t + one_day); |
| 230 | 227 |
| 231 // The message loop will exit when the mock observer is notified. | 228 // The message loop will exit when the mock observer is notified. |
| 232 MessageLoop::current()->Run(); | 229 MessageLoop::current()->Run(); |
| 233 } | 230 } |
| OLD | NEW |