| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_TEST_NACL_NACL_BROWSERTEST_UTIL_H_ | 5 #ifndef CHROME_TEST_NACL_NACL_BROWSERTEST_UTIL_H_ |
| 6 #define CHROME_TEST_NACL_NACL_BROWSERTEST_UTIL_H_ | 6 #define CHROME_TEST_NACL_NACL_BROWSERTEST_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| 11 #include "chrome/test/base/javascript_test_observer.h" | 11 #include "content/public/test/javascript_test_observer.h" |
| 12 | 12 |
| 13 // A helper base class that decodes structured automation messages of the form: | 13 // A helper base class that decodes structured automation messages of the form: |
| 14 // {"type": type_name, ...} | 14 // {"type": type_name, ...} |
| 15 class StructuredMessageHandler : public TestMessageHandler { | 15 class StructuredMessageHandler : public content::TestMessageHandler { |
| 16 public: | 16 public: |
| 17 virtual MessageResponse HandleMessage(const std::string& json) OVERRIDE; | 17 virtual MessageResponse HandleMessage(const std::string& json) OVERRIDE; |
| 18 | 18 |
| 19 // This method provides a higher-level interface for handling JSON messages | 19 // This method provides a higher-level interface for handling JSON messages |
| 20 // from the DOM automation controler. Instead of handling a string | 20 // from the DOM automation controler. Instead of handling a string |
| 21 // containing a JSON-encoded object, this specialization of TestMessageHandler | 21 // containing a JSON-encoded object, this specialization of TestMessageHandler |
| 22 // decodes the string into a dictionary. This makes it easier to send and | 22 // decodes the string into a dictionary. This makes it easier to send and |
| 23 // receive structured messages. It is assumed the dictionary will always have | 23 // receive structured messages. It is assumed the dictionary will always have |
| 24 // a "type" field that indicates the nature of message. | 24 // a "type" field that indicates the nature of message. |
| 25 virtual MessageResponse HandleStructuredMessage( | 25 virtual MessageResponse HandleStructuredMessage( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 virtual bool IsPnaclDisabled(); | 79 virtual bool IsPnaclDisabled(); |
| 80 | 80 |
| 81 // Map a file relative to the variant directory to a URL served by the test | 81 // Map a file relative to the variant directory to a URL served by the test |
| 82 // web server. | 82 // web server. |
| 83 GURL TestURL(const base::FilePath::StringType& url_fragment); | 83 GURL TestURL(const base::FilePath::StringType& url_fragment); |
| 84 | 84 |
| 85 // Load a URL and listen to automation events with a given handler. | 85 // Load a URL and listen to automation events with a given handler. |
| 86 // Returns true if the test glue function correctly. (The handler should | 86 // Returns true if the test glue function correctly. (The handler should |
| 87 // seperately indicate if the test failed.) | 87 // seperately indicate if the test failed.) |
| 88 bool RunJavascriptTest(const GURL& url, TestMessageHandler* handler); | 88 bool RunJavascriptTest(const GURL& url, content::TestMessageHandler* handler); |
| 89 | 89 |
| 90 // Run a simple test that checks that a nexe loads correctly. Useful for | 90 // Run a simple test that checks that a nexe loads correctly. Useful for |
| 91 // setting up other tests, such as checking that UMA data was logged. | 91 // setting up other tests, such as checking that UMA data was logged. |
| 92 void RunLoadTest(const base::FilePath::StringType& test_file); | 92 void RunLoadTest(const base::FilePath::StringType& test_file); |
| 93 | 93 |
| 94 // Run a test that was originally written to use NaCl's integration testing | 94 // Run a test that was originally written to use NaCl's integration testing |
| 95 // jig. These tests were originally driven by NaCl's SCons build in the | 95 // jig. These tests were originally driven by NaCl's SCons build in the |
| 96 // nacl_integration test stage on the Chrome waterfall. Changes in the | 96 // nacl_integration test stage on the Chrome waterfall. Changes in the |
| 97 // boundaries between the Chrome and NaCl repos have resulted in many of | 97 // boundaries between the Chrome and NaCl repos have resulted in many of |
| 98 // these tests having a stronger affinity with the Chrome repo. This method | 98 // these tests having a stronger affinity with the Chrome repo. This method |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 189 |
| 190 #define NACL_BROWSER_TEST_F(suite, name, body) \ | 190 #define NACL_BROWSER_TEST_F(suite, name, body) \ |
| 191 IN_PROC_BROWSER_TEST_F(suite##Newlib, name) \ | 191 IN_PROC_BROWSER_TEST_F(suite##Newlib, name) \ |
| 192 body \ | 192 body \ |
| 193 IN_PROC_BROWSER_TEST_F(suite##GLibc, MAYBE_GLIBC(name)) \ | 193 IN_PROC_BROWSER_TEST_F(suite##GLibc, MAYBE_GLIBC(name)) \ |
| 194 body \ | 194 body \ |
| 195 IN_PROC_BROWSER_TEST_F(suite##Pnacl, MAYBE_PNACL(name)) \ | 195 IN_PROC_BROWSER_TEST_F(suite##Pnacl, MAYBE_PNACL(name)) \ |
| 196 body | 196 body |
| 197 | 197 |
| 198 #endif // CHROME_TEST_NACL_NACL_BROWSERTEST_UTIL_H_ | 198 #endif // CHROME_TEST_NACL_NACL_BROWSERTEST_UTIL_H_ |
| OLD | NEW |