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

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: First round of fixes for the remote me2me tests and the associated remote_test_helper code. Created 6 years 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 host.js
34 enum Action {
35 ERROR = -1,
36 NONE = 0,
37 KEYDOWN = 1,
38 BUTTONPRESS = 2,
39 MOUSEMOVE = 3,
40 MOUSEWHEEL = 4,
41 DRAG = 5,
42 };
43
44 typedef struct {
45 Action action = Action::NONE;
46 int value = 0;
47 int modifiers = 0;
48 } Event;
49
50
51 class RemoteTestHelper {
52 public:
53
54 explicit RemoteTestHelper(content::WebContents* web_content)
55 :web_content_(web_content) {}
56
57 // We do this so we can be used in a Callback.
Jamie 2014/12/18 21:31:44 If you're sure that the reference to this object w
58 void AddRef() {}
59 void Release() {}
60
61 // Helper to execute a JavaScript code snippet and extract the boolean result.
62 static bool ExecuteScriptAndExtractBool(content::WebContents* web_contents,
63 const std::string& script);
64
65 // Helper to execute a JavaScript code snippet and extract the int result.
66 static int ExecuteScriptAndExtractInt(content::WebContents* web_contents,
67 const std::string& script);
68
69 // Helper to execute a JavaScript code snippet and extract the string result.
70 static std::string ExecuteScriptAndExtractString(
71 content::WebContents* web_contents, const std::string& script);
72
73 // Helper method to set the clear the last event
74 void ClearLastEvent();
75
76 // Helper method to get the last event
77 void GetLastEvent(Event* event);
78
79 // Execute an RPC call
80 void ExecuteRpc(const std::string& method) {
81 ExecuteRpc(method,
82 base::TimeDelta::FromSeconds(2),
83 base::TimeDelta::FromMilliseconds(500));
84 }
85 void ExecuteRpc(const std::string& method,
86 base::TimeDelta timeout,
87 base::TimeDelta interval);
88
89 private:
90 content::WebContents* web_content_;
91
92 // Check for a valid last event
93 bool IsValidEvent();
94
95 DISALLOW_COPY_AND_ASSIGN(RemoteTestHelper);
96 };
97
98 } // namespace remoting
99
100 #endif // CHROME_TEST_REMOTING_REMOTE_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698