ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / chromeos / login / test / js_checker.h
blobe2979b6b0bfa2e0c36fc04cbe71be81d11813661
1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_TEST_JS_CHECKER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_TEST_JS_CHECKER_H_
8 #include <string>
10 namespace content {
11 class WebContents;
14 namespace chromeos {
15 namespace test {
17 // Utility class for tests that allows us to evalute and check JavaScript
18 // expressions inside given web contents. All calls are made synchronously.
19 class JSChecker {
20 public:
21 JSChecker();
22 explicit JSChecker(content::WebContents* web_contents);
24 // Evaluates |expression|.
25 void Evaluate(const std::string& expression);
27 // Executes |expression|. Doesn't require a correct command.
28 void Execute(const std::string& expression);
30 // Evaluates |expression| and returns its result.
31 bool GetBool(const std::string& expression);
32 int GetInt(const std::string& expression);
33 std::string GetString(const std::string& expression);
35 // Checks truthfulness of the given |expression|.
36 void ExpectTrue(const std::string& expression);
37 void ExpectFalse(const std::string& expression);
39 // Compares result of |expression| with |result|.
40 void ExpectEQ(const std::string& expression, int result);
41 void ExpectNE(const std::string& expression, int result);
42 void ExpectEQ(const std::string& expression, const std::string& result);
43 void ExpectNE(const std::string& expression, const std::string& result);
45 void set_web_contents(content::WebContents* web_contents) {
46 web_contents_ = web_contents;
49 private:
50 void GetBoolImpl(const std::string& expression, bool* result);
51 void GetIntImpl(const std::string& expression, int* result);
52 void GetStringImpl(const std::string& expression, std::string* result);
54 content::WebContents* web_contents_;
57 } // namespace test
58 } // namespace chromeos
60 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_TEST_JS_CHECKER_H_