| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_form_database_service.h" | 7 #include "android_webview/browser/aw_form_database_service.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 service_.reset(new AwFormDatabaseService(temp_dir_.path())); | 42 service_.reset(new AwFormDatabaseService(temp_dir_.path())); |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual void TearDown() { | 45 virtual void TearDown() { |
| 46 service_->Shutdown(); | 46 service_->Shutdown(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // The path to the temporary directory used for the test operations. | 49 // The path to the temporary directory used for the test operations. |
| 50 base::ScopedTempDir temp_dir_; | 50 base::ScopedTempDir temp_dir_; |
| 51 // A message loop for UI thread. | 51 // A message loop for UI thread. |
| 52 MessageLoop message_loop_; | 52 base::MessageLoop message_loop_; |
| 53 content::TestBrowserThread ui_thread_; | 53 content::TestBrowserThread ui_thread_; |
| 54 content::TestBrowserThread db_thread_; | 54 content::TestBrowserThread db_thread_; |
| 55 JNIEnv* env_; | 55 JNIEnv* env_; |
| 56 | 56 |
| 57 scoped_ptr<AwFormDatabaseService> service_; | 57 scoped_ptr<AwFormDatabaseService> service_; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 TEST_F(AwFormDatabaseServiceTest, HasAndClearFormData) { | 60 TEST_F(AwFormDatabaseServiceTest, HasAndClearFormData) { |
| 61 EXPECT_FALSE(service_->HasFormData()); | 61 EXPECT_FALSE(service_->HasFormData()); |
| 62 std::vector<FormFieldData> fields; | 62 std::vector<FormFieldData> fields; |
| 63 FormFieldData field; | 63 FormFieldData field; |
| 64 field.name = ASCIIToUTF16("foo"); | 64 field.name = ASCIIToUTF16("foo"); |
| 65 field.value = ASCIIToUTF16("bar"); | 65 field.value = ASCIIToUTF16("bar"); |
| 66 fields.push_back(field); | 66 fields.push_back(field); |
| 67 service_->get_autofill_webdata_service()->AddFormFields(fields); | 67 service_->get_autofill_webdata_service()->AddFormFields(fields); |
| 68 EXPECT_TRUE(service_->HasFormData()); | 68 EXPECT_TRUE(service_->HasFormData()); |
| 69 service_->ClearFormData(); | 69 service_->ClearFormData(); |
| 70 EXPECT_FALSE(service_->HasFormData()); | 70 EXPECT_FALSE(service_->HasFormData()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 } // namespace android_webview | 73 } // namespace android_webview |
| OLD | NEW |