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

Side by Side Diff: webkit/tools/test_shell/layout_test_controller.h

Issue 10536207: Remove layoutTestController from test_shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: really fix mac Created 8 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 (c) 2012 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 /*
6 LayoutTestController class:
7 Bound to a JavaScript window.layoutTestController object using the
8 CppBoundClass::BindToJavascript(), this allows layout tests that are run in
9 the test_shell (or, in principle, any web page loaded into a client app built
10 with this class) to control various aspects of how the tests are run and what
11 sort of output they produce.
12 */
13
14 #ifndef WEBKIT_TOOLS_TEST_SHELL_LAYOUT_TEST_CONTROLLER_H_
15 #define WEBKIT_TOOLS_TEST_SHELL_LAYOUT_TEST_CONTROLLER_H_
16
17 #include <queue>
18
19 #include "base/memory/weak_ptr.h"
20 #include "base/timer.h"
21 #include "base/string16.h"
22 #include "webkit/glue/cpp_bound_class.h"
23
24 class TestShell;
25
26 class LayoutTestController : public webkit_glue::CppBoundClass {
27 public:
28 // Builds the property and method lists needed to bind this class to a JS
29 // object.
30 LayoutTestController(TestShell* shell);
31 virtual ~LayoutTestController();
32
33 // By default, tests end when page load is complete. These methods are used
34 // to delay the completion of the test until notifyDone is called.
35 void waitUntilDone(const webkit_glue::CppArgumentList& args,
36 webkit_glue::CppVariant* result);
37 void notifyDone(const webkit_glue::CppArgumentList& args,
38 webkit_glue::CppVariant* result);
39
40 // The fallback method is called when a nonexistent method is called on
41 // the layout test controller object.
42 // It is usefull to catch typos in the JavaScript code (a few layout tests
43 // do have typos in them) and it allows the script to continue running in
44 // that case (as the Mac does).
45 void fallbackMethod(const webkit_glue::CppArgumentList& args,
46 webkit_glue::CppVariant* result);
47
48 public:
49 // The following methods are not exposed to JavaScript.
50 void SetWorkQueueFrozen(bool frozen) { work_queue_.set_frozen(frozen); }
51
52 bool AcceptsEditing() { return accepts_editing_; }
53 bool CanOpenWindows() { return can_open_windows_; }
54 bool StopProvisionalFrameLoads() { return stop_provisional_frame_loads_; }
55
56 // Called by the webview delegate when the toplevel frame load is done.
57 void LocationChangeDone();
58
59 // Called by the webview delegate when the policy delegate runs if the
60 // waitForPolicyDelegate was called.
61 void PolicyDelegateDone();
62
63 // Reinitializes all static values. The Reset() method should be called
64 // before the start of each test (currently from
65 // TestShell::RunFileTest).
66 void Reset();
67
68 // A single item in the work queue.
69 class WorkItem {
70 public:
71 virtual ~WorkItem() {}
72
73 // Returns true if this started a load.
74 virtual bool Run(TestShell* shell) = 0;
75 };
76
77 // Used to clear the value of shell_ from test_shell_tests.
78 static void ClearShell() { shell_ = NULL; }
79
80 private:
81 friend class WorkItem;
82
83 // Helper class for managing events queued by methods like queueLoad or
84 // queueScript.
85 class WorkQueue {
86 public:
87 WorkQueue();
88 virtual ~WorkQueue();
89 void ProcessWorkSoon();
90
91 // Reset the state of the class between tests.
92 void Reset();
93
94 void AddWork(WorkItem* work);
95
96 void set_frozen(bool frozen) { frozen_ = frozen; }
97 bool empty() { return queue_.empty(); }
98
99 private:
100 void ProcessWork();
101
102 base::OneShotTimer<WorkQueue> timer_;
103 std::queue<WorkItem*> queue_;
104 bool frozen_;
105 };
106
107 void notifyDoneTimedOut();
108
109 void LogErrorToConsole(const std::string& text);
110
111 void completeNotifyDone(bool is_timeout);
112
113 // Used for test timeouts.
114 // TODO(ojan): Use base::OneShotTimer.
115 base::WeakPtrFactory<LayoutTestController> weak_factory_;
116
117 // Non-owning pointer. The LayoutTestController is owned by the host.
118 static TestShell* shell_;
119
120 // If true, the element will be treated as editable. This value is returned
121 // from various editing callbacks that are called just before edit operations
122 // are allowed.
123 static bool accepts_editing_;
124
125 // If true, new windows can be opened via javascript or by plugins. By
126 // default, set to false and can be toggled to true using
127 // setCanOpenWindows().
128 static bool can_open_windows_;
129
130 // When reset is called, go through and close all but the main test shell
131 // window. By default, set to true but toggled to false using
132 // setCloseRemainingWindowsWhenComplete().
133 static bool close_remaining_windows_;
134
135 // If true, stops provisional frame loads during the
136 // DidStartProvisionalLoadForFrame callback.
137 static bool stop_provisional_frame_loads_;
138
139 // If true, don't dump output until notifyDone is called.
140 static bool wait_until_done_;
141
142 static WorkQueue work_queue_;
143 };
144
145 #endif // WEBKIT_TOOLS_TEST_SHELL_LAYOUT_TEST_CONTROLLER_H_
OLDNEW
« no previous file with comments | « webkit/glue/iframe_redirect_unittest.cc ('k') | webkit/tools/test_shell/layout_test_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698