193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)/*
293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Copyright (C) 2013 Google Inc. All rights reserved.
393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * modification, are permitted provided that the following conditions
693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * are met:
793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * 1.  Redistributions of source code must retain the above copyright
993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     notice, this list of conditions and the following disclaimer.
1093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * 2.  Redistributions in binary form must reproduce the above copyright
1193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     notice, this list of conditions and the following disclaimer in the
1293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     documentation and/or other materials provided with the distribution.
1393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
1493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
1593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
1893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) */
2593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
2693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#ifndef WebUnitTestSupport_h
2793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#define WebUnitTestSupport_h
2893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
2993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "WebCommon.h"
3000d3faa021f1e9934a353eeebe4e57e354856cf6Ben Murdoch#include "WebData.h"
3193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "WebString.h"
3293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
3351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)namespace blink {
3493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
3593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)class WebLayerTreeView;
3693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)class WebURL;
3793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)class WebURLResponse;
3893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)struct WebURLError;
3993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
4093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)class WebUnitTestSupport {
4193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)public:
4293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    virtual void registerMockedURL(const WebURL&, const WebURLResponse&, const WebString& filePath) { }
4393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
4493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // Registers the error to be returned when |url| is requested.
4593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    virtual void registerMockedErrorURL(const WebURL&, const WebURLResponse&, const WebURLError&) { }
4693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
4793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // Unregisters URLs so they are no longer mocked.
4893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    virtual void unregisterMockedURL(const WebURL&) { }
4993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    virtual void unregisterAllMockedURLs() { }
5093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
5193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // Causes all pending asynchronous requests to be served. When this method
5293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // returns all the pending requests have been processed.
5393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    virtual void serveAsynchronousMockedRequests() { }
5493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
5593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // Returns the root directory of the WebKit code.
5693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    virtual WebString webKitRootDir() { return WebString(); }
5793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
5893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // Constructs a WebLayerTreeView set up with reasonable defaults for
5993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // testing.
6093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    virtual WebLayerTreeView* createLayerTreeViewForTesting() { return 0; }
6193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
6200d3faa021f1e9934a353eeebe4e57e354856cf6Ben Murdoch    virtual WebData readFromFile(const WebString& path) { return WebData(); }
6393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)};
6493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
6593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)}
6693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
6793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#endif // WebUnitTestSupport_h
68