Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: components/autofill/content/browser/autofill_driver_impl_unittest.cc

Issue 17450010: Create AutofillDriverImpl unit test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <algorithm>
6 #include <vector>
7
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h"
blundell 2013/06/19 17:49:37 Is there a way around creating the real AutofillMa
Ilya Sherman 2013/06/20 00:07:16 You can probably use components/autofill/browser/t
blundell 2013/06/21 12:55:23 Done.
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
blundell 2013/06/19 17:49:37 My understanding is that I can't change this to be
Ilya Sherman 2013/06/20 00:07:16 Yeah, that seems to be what Jói concluded as well.
11 #include "components/autofill/browser/autofill_external_delegate.h"
12 #include "components/autofill/browser/autofill_manager.h"
13 #include "components/autofill/content/browser/autofill_driver_impl.h"
14 #include "content/public/browser/web_contents.h"
15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 namespace autofill {
19
20 class AutofillManagerMock : public AutofillManager {
Ilya Sherman 2013/06/20 00:07:16 nit: "MockAutofillManager"
blundell 2013/06/21 12:55:23 Done.
21 public:
22 AutofillManagerMock(AutofillDriver* driver,
23 autofill::AutofillManagerDelegate* delegate,
Ilya Sherman 2013/06/20 00:07:16 nit: Since this code is in the autofill namespace
blundell 2013/06/21 12:55:23 Done.
24 const std::string& app_locale,
25 AutofillDownloadManagerState enable_download_manager)
26 : AutofillManager(driver, delegate, app_locale, enable_download_manager) {
27 }
28 virtual ~AutofillManagerMock() {}
29
30 MOCK_METHOD1(SetExternalDelegate, void(AutofillExternalDelegate*));
31 };
32
33 class AutofillDriverImplTest : public ChromeRenderViewHostTestHarness {
34 public:
35 virtual void SetUp() OVERRIDE {
36 ChromeRenderViewHostTestHarness::SetUp();
37
38 TabAutofillManagerDelegate::CreateForWebContents(web_contents());
39 TabAutofillManagerDelegate* delegate =
40 TabAutofillManagerDelegate::FromWebContents(web_contents());
41
42 std::string app_locale = "en-US";
43 AutofillManager::AutofillDownloadManagerState download_state =
44 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER;
45 driver_ = new AutofillDriverImpl(web_contents(),
46 delegate,
47 app_locale,
48 download_state,
49 true);
50 autofill_manager_ = new AutofillManagerMock(driver_,
51 delegate, app_locale, download_state);
52 driver_->set_autofill_manager(
53 scoped_ptr<AutofillManager>(autofill_manager_));
Ilya Sherman 2013/06/20 00:07:16 note: If you take my advice about creating a subcl
blundell 2013/06/21 12:55:23 Done.
54 }
55
56 virtual void TearDown() OVERRIDE {
57 delete driver_;
58 ChromeRenderViewHostTestHarness::TearDown();
59 }
60
61 protected:
62 // Owned by this object.
63 AutofillDriverImpl* driver_;
blundell 2013/06/19 17:49:37 I had made this a scoped ptr but got complaints ab
Ilya Sherman 2013/06/20 00:07:16 Please create a "class TestAutofillDriverImpl : pu
blundell 2013/06/21 12:55:23 Done.
64 // Owned by |driver_|.
65 AutofillManagerMock* autofill_manager_;
66 };
67
68 TEST_F(AutofillDriverImplTest, SetExternalDelegate) {
69 EXPECT_CALL(*autofill_manager_, SetExternalDelegate(NULL));
70 driver_->SetAutofillExternalDelegate(scoped_ptr<AutofillExternalDelegate>());
Ilya Sherman 2013/06/20 00:07:16 Hmm, this is testing deprecated functionality, i.e
blundell 2013/06/21 12:55:23 Replaced this test with tests to test response to
71 }
72
73 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698