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

Side by Side Diff: chrome/test/remoting/remote_test_helper.h

Issue 807343002: Adding the first set of remote test cases and associated framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changing enum naming format to eliminate name conflict. Created 5 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2014 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 CHROME_TEST_REMOTING_REMOTE_TEST_HELPER_H_
6 #define CHROME_TEST_REMOTING_REMOTE_TEST_HELPER_H_
7
8 #include "base/debug/stack_trace.h"
9 #include "base/timer/timer.h"
10 #include "content/public/test/browser_test_utils.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace {
14
15 // ASSERT_TRUE can only be used in void returning functions. This version
16 // should be used in non-void-returning functions.
17 inline void _ASSERT_TRUE(bool condition) {
18 if (!condition) {
19 // ASSERT_TRUE only prints the first call frame in the error message.
20 // In our case, this is the _ASSERT_TRUE wrapper function, which is not
21 // useful. To help with debugging, we will dump the full callstack.
22 LOG(ERROR) << "Assertion failed.";
23 LOG(ERROR) << base::debug::StackTrace().ToString();
24 }
25 ASSERT_TRUE(condition);
26 return;
27 }
28
29 } // namespace
30
31 namespace remoting {
32
33 // Mirrored in remoting/tools/remote_test_helper/host.js
34 enum class Action : int {
35 Error = 0,
36 None = 1,
37 Keydown = 2,
38 Buttonpress = 3,
39 Mousemove = 4,
40 Mousewheel = 5,
41 Drag = 6,
42 };
43
44 struct Event {
45 Event();
46
47 Action action;
48 int value;
49 int modifiers;
50 };
51
52
53 class RemoteTestHelper {
54 public:
55 explicit RemoteTestHelper(content::WebContents* web_content);
56
57 // Helper to execute a JavaScript code snippet and extract the boolean result.
58 static bool ExecuteScriptAndExtractBool(content::WebContents* web_contents,
59 const std::string& script);
60
61 // Helper to execute a JavaScript code snippet and extract the int result.
62 static int ExecuteScriptAndExtractInt(content::WebContents* web_contents,
63 const std::string& script);
64
65 // Helper to execute a JavaScript code snippet and extract the string result.
66 static std::string ExecuteScriptAndExtractString(
67 content::WebContents* web_contents, const std::string& script);
68
69 // Helper method to set the clear the last event
70 void ClearLastEvent();
71
72 // Helper method to get the last event
73 void GetLastEvent(Event* event);
74
75 // Execute an RPC call
76 void ExecuteRpc(const std::string& method) {
77 ExecuteRpc(method,
78 base::TimeDelta::FromSeconds(2),
79 base::TimeDelta::FromMilliseconds(500));
80 }
81 void ExecuteRpc(const std::string& method,
82 base::TimeDelta timeout,
83 base::TimeDelta interval);
84
85 private:
86 content::WebContents* web_content_;
87
88 // Check for a valid last event
89 bool IsValidEvent();
90 DISALLOW_COPY_AND_ASSIGN(RemoteTestHelper);
91 };
92
93 } // namespace remoting
94
95 #endif // CHROME_TEST_REMOTING_REMOTE_TEST_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/test/remoting/remote_desktop_browsertest.cc ('k') | chrome/test/remoting/remote_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698