test_autofill_driver.h revision f2477e01787aa58f445919b809d89e252beef54f
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#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_DRIVER_H_ 6#define COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_DRIVER_H_ 7 8#include "base/basictypes.h" 9#include "base/compiler_specific.h" 10#include "base/memory/ref_counted.h" 11#include "components/autofill/core/browser/autofill_driver.h" 12#include "content/public/browser/web_contents_observer.h" 13 14namespace autofill { 15 16// This class is only for easier writing of tests. 17// TODO(blundell): Eliminate this class being a WebContentsObserver once 18// autofill shared code no longer needs knowledge of WebContents. 19class TestAutofillDriver : public AutofillDriver, 20 public content::WebContentsObserver { 21 public: 22 explicit TestAutofillDriver(content::WebContents* web_contents); 23 virtual ~TestAutofillDriver(); 24 25 // AutofillDriver implementation. 26 virtual bool IsOffTheRecord() const OVERRIDE; 27 // Returns the value passed in to the last call to |SetURLRequestContext()| 28 // or NULL if that method has never been called. 29 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; 30 virtual content::WebContents* GetWebContents() OVERRIDE; 31 virtual base::SequencedWorkerPool* GetBlockingPool() OVERRIDE; 32 virtual bool RendererIsAvailable() OVERRIDE; 33 virtual void SetRendererActionOnFormDataReception( 34 RendererFormDataAction action) OVERRIDE; 35 virtual void SendFormDataToRenderer(int query_id, 36 const FormData& data) OVERRIDE; 37 virtual void SendAutofillTypePredictionsToRenderer( 38 const std::vector<FormStructure*>& forms) OVERRIDE; 39 virtual void RendererShouldAcceptDataListSuggestion( 40 const base::string16& value) OVERRIDE; 41 virtual void RendererShouldAcceptPasswordAutofillSuggestion( 42 const base::string16& username) OVERRIDE; 43 virtual void RendererShouldClearFilledForm() OVERRIDE; 44 virtual void RendererShouldClearPreviewedForm() OVERRIDE; 45 virtual void RendererShouldSetNodeText(const base::string16& value) OVERRIDE; 46 47 // Methods that tests can use to specialize functionality. 48 49 // Sets the URL request context for this instance. |url_request_context| 50 // should outlive this instance. 51 void SetURLRequestContext(net::URLRequestContextGetter* url_request_context); 52 53 private: 54 scoped_refptr<base::SequencedWorkerPool> blocking_pool_; 55 net::URLRequestContextGetter* url_request_context_; 56 57 DISALLOW_COPY_AND_ASSIGN(TestAutofillDriver); 58}; 59 60} // namespace autofill 61 62#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_DRIVER_H_ 63