~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
7
 * 1. Redistributions of source code must retain the above copyright
 
8
 *    notice, this list of conditions and the following disclaimer.
 
9
 * 2. Redistributions in binary form must reproduce the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer in the
 
11
 *    documentation and/or other materials provided with the distribution.
 
12
 *
 
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 
23
 * THE POSSIBILITY OF SUCH DAMAGE.
 
24
 */
 
25
 
 
26
#ifndef InjectedBundle_h
 
27
#define InjectedBundle_h
 
28
 
 
29
#include "AccessibilityController.h"
 
30
#include "EventSendingController.h"
 
31
#include "GCController.h"
 
32
#include "TestRunner.h"
 
33
#include "TextInputController.h"
 
34
#include <WebKit2/WKBase.h>
 
35
#include <WebKit2/WKRetainPtr.h>
 
36
#include <wtf/OwnPtr.h>
 
37
#include <wtf/RefPtr.h>
 
38
#include <wtf/Vector.h>
 
39
 
 
40
#include <sstream>
 
41
 
 
42
namespace WTF {
 
43
class StringBuilder;
 
44
}
 
45
 
 
46
namespace WTR {
 
47
 
 
48
class InjectedBundlePage;
 
49
 
 
50
class InjectedBundle {
 
51
public:
 
52
    static InjectedBundle& shared();
 
53
 
 
54
    // Initialize the InjectedBundle.
 
55
    void initialize(WKBundleRef, WKTypeRef initializationUserData);
 
56
 
 
57
    WKBundleRef bundle() const { return m_bundle; }
 
58
    WKBundlePageGroupRef pageGroup() const { return m_pageGroup; }
 
59
 
 
60
    TestRunner* testRunner() { return m_testRunner.get(); }
 
61
    GCController* gcController() { return m_gcController.get(); }
 
62
    EventSendingController* eventSendingController() { return m_eventSendingController.get(); }
 
63
    TextInputController* textInputController() { return m_textInputController.get(); }
 
64
    AccessibilityController* accessibilityController() { return m_accessibilityController.get(); }
 
65
 
 
66
    InjectedBundlePage* page() const;
 
67
    size_t pageCount() const { return m_pages.size(); }
 
68
    void closeOtherPages();
 
69
 
 
70
    void dumpBackForwardListsForAllPages();
 
71
 
 
72
    void done();
 
73
    WTF::StringBuilder* stringBuilder() { return m_stringBuilder.get(); }
 
74
    void setPixelResult(WKImageRef image) { m_pixelResult = image; }
 
75
    void setRepaintRects(WKArrayRef rects) { m_repaintRects = rects; }
 
76
 
 
77
    bool isTestRunning() { return m_state == Testing; }
 
78
 
 
79
    WKBundleFrameRef topLoadingFrame() { return m_topLoadingFrame; }
 
80
    void setTopLoadingFrame(WKBundleFrameRef frame) { m_topLoadingFrame = frame; }
 
81
 
 
82
    bool shouldDumpPixels() const { return m_dumpPixels; }
 
83
    bool useWaitToDumpWatchdogTimer() const { return m_useWaitToDumpWatchdogTimer; }
 
84
    
 
85
    void postNewBeforeUnloadReturnValue(bool);
 
86
    void postAddChromeInputField();
 
87
    void postRemoveChromeInputField();
 
88
    void postFocusWebView();
 
89
    void postSetBackingScaleFactor(double);
 
90
    void postSetWindowIsKey(bool);
 
91
    void postSimulateWebNotificationClick(uint64_t notificationID);
 
92
 
 
93
    // Geolocation.
 
94
    void setGeolocationPermission(bool);
 
95
    void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
 
96
    void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage);
 
97
 
 
98
    // Policy delegate.
 
99
    void setCustomPolicyDelegate(bool enabled, bool permissive);
 
100
 
 
101
    // Work queue.
 
102
    bool shouldProcessWorkQueue() const;
 
103
    void processWorkQueue();
 
104
    void queueBackNavigation(unsigned howFarBackward);
 
105
    void queueForwardNavigation(unsigned howFarForward);
 
106
    void queueLoad(WKStringRef url, WKStringRef target);
 
107
    void queueLoadHTMLString(WKStringRef content, WKStringRef baseURL = 0, WKStringRef unreachableURL = 0);
 
108
    void queueReload();
 
109
    void queueLoadingScript(WKStringRef script);
 
110
    void queueNonLoadingScript(WKStringRef script);
 
111
 
 
112
private:
 
113
    InjectedBundle();
 
114
    ~InjectedBundle();
 
115
 
 
116
    static void didCreatePage(WKBundleRef, WKBundlePageRef, const void* clientInfo);
 
117
    static void willDestroyPage(WKBundleRef, WKBundlePageRef, const void* clientInfo);
 
118
    static void didInitializePageGroup(WKBundleRef, WKBundlePageGroupRef, const void* clientInfo);
 
119
    static void didReceiveMessage(WKBundleRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo);
 
120
    static void didReceiveMessageToPage(WKBundleRef, WKBundlePageRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo);
 
121
 
 
122
    void didCreatePage(WKBundlePageRef);
 
123
    void willDestroyPage(WKBundlePageRef);
 
124
    void didInitializePageGroup(WKBundlePageGroupRef);
 
125
    void didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody);
 
126
    void didReceiveMessageToPage(WKBundlePageRef, WKStringRef messageName, WKTypeRef messageBody);
 
127
 
 
128
    void platformInitialize(WKTypeRef initializationUserData);
 
129
    void resetLocalSettings();
 
130
 
 
131
    void beginTesting(WKDictionaryRef initialSettings);
 
132
 
 
133
    bool booleanForKey(WKDictionaryRef, const char* key);
 
134
 
 
135
    WKBundleRef m_bundle;
 
136
    WKBundlePageGroupRef m_pageGroup;
 
137
    Vector<OwnPtr<InjectedBundlePage> > m_pages;
 
138
 
 
139
    RefPtr<AccessibilityController> m_accessibilityController;
 
140
    RefPtr<TestRunner> m_testRunner;
 
141
    RefPtr<GCController> m_gcController;
 
142
    RefPtr<EventSendingController> m_eventSendingController;
 
143
    RefPtr<TextInputController> m_textInputController;
 
144
 
 
145
    WKBundleFrameRef m_topLoadingFrame;
 
146
 
 
147
    OwnPtr<WTF::StringBuilder> m_stringBuilder;
 
148
    
 
149
    enum State {
 
150
        Idle,
 
151
        Testing,
 
152
        Stopping
 
153
    };
 
154
    State m_state;
 
155
 
 
156
    bool m_dumpPixels;
 
157
    bool m_useWaitToDumpWatchdogTimer;
 
158
    bool m_useWorkQueue;
 
159
 
 
160
    WKRetainPtr<WKImageRef> m_pixelResult;
 
161
    WKRetainPtr<WKArrayRef> m_repaintRects;
 
162
};
 
163
 
 
164
} // namespace WTR
 
165
 
 
166
#endif // InjectedBundle_h