| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/ref_counted.h" | 7 #include "base/memory/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/base/chrome_render_view_host_test_harness.h" |
| 13 #include "chrome/test/base/testing_browser_process.h" | 14 #include "chrome/test/base/testing_browser_process.h" |
| 14 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
| 15 #include "content/browser/renderer_host/test_render_view_host.h" | |
| 16 #include "content/browser/tab_contents/test_tab_contents.h" | 16 #include "content/browser/tab_contents/test_tab_contents.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "webkit/glue/form_data.h" | 19 #include "webkit/glue/form_data.h" |
| 20 | 20 |
| 21 using testing::_; | 21 using testing::_; |
| 22 using webkit_glue::FormData; | 22 using webkit_glue::FormData; |
| 23 | 23 |
| 24 class MockWebDataService : public WebDataService { | 24 class MockWebDataService : public WebDataService { |
| 25 public: | 25 public: |
| 26 MOCK_METHOD1(AddFormFields, | 26 MOCK_METHOD1(AddFormFields, |
| 27 void(const std::vector<webkit_glue::FormField>&)); // NOLINT | 27 void(const std::vector<webkit_glue::FormField>&)); // NOLINT |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 class AutocompleteHistoryManagerTest : public RenderViewHostTestHarness { | 30 class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness { |
| 31 protected: | 31 protected: |
| 32 AutocompleteHistoryManagerTest() | 32 AutocompleteHistoryManagerTest() |
| 33 : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()) { | 33 : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()) { |
| 34 } | 34 } |
| 35 | 35 |
| 36 virtual void SetUp() { | 36 virtual void SetUp() { |
| 37 RenderViewHostTestHarness::SetUp(); | 37 ChromeRenderViewHostTestHarness::SetUp(); |
| 38 web_data_service_ = new MockWebDataService(); | 38 web_data_service_ = new MockWebDataService(); |
| 39 autocomplete_manager_.reset(new AutocompleteHistoryManager( | 39 autocomplete_manager_.reset(new AutocompleteHistoryManager( |
| 40 contents(), &profile_, web_data_service_)); | 40 contents(), &profile_, web_data_service_)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 BrowserThread ui_thread_; | 43 BrowserThread ui_thread_; |
| 44 | 44 |
| 45 TestingProfile profile_; | 45 TestingProfile profile_; |
| 46 scoped_refptr<MockWebDataService> web_data_service_; | 46 scoped_refptr<MockWebDataService> web_data_service_; |
| 47 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_; | 47 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 webkit_glue::FormField search_field; | 124 webkit_glue::FormField search_field; |
| 125 search_field.label = ASCIIToUTF16("Search"); | 125 search_field.label = ASCIIToUTF16("Search"); |
| 126 search_field.name = ASCIIToUTF16("search"); | 126 search_field.name = ASCIIToUTF16("search"); |
| 127 search_field.value = ASCIIToUTF16("my favorite query"); | 127 search_field.value = ASCIIToUTF16("my favorite query"); |
| 128 search_field.form_control_type = ASCIIToUTF16("search"); | 128 search_field.form_control_type = ASCIIToUTF16("search"); |
| 129 form.fields.push_back(search_field); | 129 form.fields.push_back(search_field); |
| 130 | 130 |
| 131 EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1); | 131 EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1); |
| 132 autocomplete_manager_->OnFormSubmitted(form); | 132 autocomplete_manager_->OnFormSubmitted(form); |
| 133 } | 133 } |
| OLD | NEW |