Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 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/ref_counted.h" | 7 #include "base/ref_counted.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/task.h" | 9 #include "base/task.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/autocomplete_history_manager.h" | 11 #include "chrome/browser/autocomplete_history_manager.h" |
| 12 #include "chrome/browser/webdata/web_data_service.h" | 12 #include "chrome/browser/webdata/web_data_service.h" |
| 13 #include "chrome/test/testing_browser_process.h" | |
| 13 #include "chrome/test/testing_profile.h" | 14 #include "chrome/test/testing_profile.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "webkit/glue/form_data.h" | 17 #include "webkit/glue/form_data.h" |
| 17 | 18 |
| 18 using testing::_; | 19 using testing::_; |
| 19 using webkit_glue::FormData; | 20 using webkit_glue::FormData; |
| 20 | 21 |
| 21 class MockWebDataService : public WebDataService { | 22 class MockWebDataService : public WebDataService { |
| 22 public: | 23 public: |
| 23 MOCK_METHOD1(AddFormFields, | 24 MOCK_METHOD1(AddFormFields, |
| 24 void(const std::vector<webkit_glue::FormField>&)); // NOLINT | 25 void(const std::vector<webkit_glue::FormField>&)); // NOLINT |
| 25 }; | 26 }; |
| 26 | 27 |
| 27 class AutocompleteHistoryManagerTest : public testing::Test { | 28 class AutocompleteHistoryManagerTest : public testing::Test { |
|
sky
2011/02/14 17:01:19
TestingBrowserProcessTest?
| |
| 28 protected: | 29 protected: |
| 29 AutocompleteHistoryManagerTest() | 30 AutocompleteHistoryManagerTest() |
| 30 : ui_thread_(BrowserThread::UI, &message_loop_) { | 31 : ui_thread_(BrowserThread::UI, &message_loop_) { |
| 31 } | 32 } |
| 32 | 33 |
| 33 virtual void SetUp() { | 34 virtual void SetUp() { |
| 34 web_data_service_ = new MockWebDataService(); | 35 web_data_service_ = new MockWebDataService(); |
| 35 autocomplete_manager_.reset( | 36 autocomplete_manager_.reset( |
| 36 new AutocompleteHistoryManager(&profile_, web_data_service_)); | 37 new AutocompleteHistoryManager(&profile_, web_data_service_)); |
| 37 } | 38 } |
| 38 | 39 |
| 40 ScopedTestingBrowserProcess browser_process_; | |
| 41 | |
| 39 MessageLoopForUI message_loop_; | 42 MessageLoopForUI message_loop_; |
| 40 BrowserThread ui_thread_; | 43 BrowserThread ui_thread_; |
| 41 | 44 |
| 42 TestingProfile profile_; | 45 TestingProfile profile_; |
| 43 scoped_refptr<MockWebDataService> web_data_service_; | 46 scoped_refptr<MockWebDataService> web_data_service_; |
| 44 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_; | 47 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_; |
| 45 }; | 48 }; |
| 46 | 49 |
| 47 // Tests that credit card numbers are not sent to the WebDatabase to be saved. | 50 // Tests that credit card numbers are not sent to the WebDatabase to be saved. |
| 48 TEST_F(AutocompleteHistoryManagerTest, CreditCardNumberValue) { | 51 TEST_F(AutocompleteHistoryManagerTest, CreditCardNumberValue) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 ASCIIToUTF16("ssn"), | 106 ASCIIToUTF16("ssn"), |
| 104 ASCIIToUTF16("078-05-1120"), | 107 ASCIIToUTF16("078-05-1120"), |
| 105 ASCIIToUTF16("text"), | 108 ASCIIToUTF16("text"), |
| 106 20, | 109 20, |
| 107 false); | 110 false); |
| 108 form.fields.push_back(ssn); | 111 form.fields.push_back(ssn); |
| 109 | 112 |
| 110 EXPECT_CALL(*web_data_service_, AddFormFields(_)).Times(0); | 113 EXPECT_CALL(*web_data_service_, AddFormFields(_)).Times(0); |
| 111 autocomplete_manager_->OnFormSubmitted(form); | 114 autocomplete_manager_->OnFormSubmitted(form); |
| 112 } | 115 } |
| OLD | NEW |