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_
17 // Utility class for tests that allows us to evalute and check JavaScript
18 // expressions inside given web contents. All calls are made synchronously.
22 explicit JSChecker(content::WebContents
* web_contents
);
24 // Evaluates |expression|. Evaluation will be completed when this function
26 void Evaluate(const std::string
& expression
);
28 // Executes |expression|. Doesn't require a correct command. Command will be
29 // queued up and executed later. This function will return immediately.
30 void ExecuteAsync(const std::string
& expression
);
32 // Evaluates |expression| and returns its result.
33 bool GetBool(const std::string
& expression
);
34 int GetInt(const std::string
& expression
);
35 std::string
GetString(const std::string
& expression
);
37 // Checks truthfulness of the given |expression|.
38 void ExpectTrue(const std::string
& expression
);
39 void ExpectFalse(const std::string
& expression
);
41 // Compares result of |expression| with |result|.
42 void ExpectEQ(const std::string
& expression
, int result
);
43 void ExpectNE(const std::string
& expression
, int result
);
44 void ExpectEQ(const std::string
& expression
, const std::string
& result
);
45 void ExpectNE(const std::string
& expression
, const std::string
& result
);
47 void set_web_contents(content::WebContents
* web_contents
) {
48 web_contents_
= web_contents
;
52 void GetBoolImpl(const std::string
& expression
, bool* result
);
53 void GetIntImpl(const std::string
& expression
, int* result
);
54 void GetStringImpl(const std::string
& expression
, std::string
* result
);
56 content::WebContents
* web_contents_
;
60 } // namespace chromeos
62 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_TEST_JS_CHECKER_H_