| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_TEST_PPAPI_PPAPI_TEST_H_ |
| 6 #define CHROME_TEST_PPAPI_PPAPI_TEST_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 13 #include "base/timer.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" |
| 17 |
| 18 namespace content { |
| 19 class RenderViewHost; |
| 20 } |
| 21 |
| 22 class PPAPITestBase : public InProcessBrowserTest { |
| 23 public: |
| 24 PPAPITestBase(); |
| 25 |
| 26 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 27 |
| 28 virtual std::string BuildQuery(const std::string& base, |
| 29 const std::string& test_case) = 0; |
| 30 |
| 31 // Returns the URL to load for file: tests. |
| 32 GURL GetTestFileUrl(const std::string& test_case); |
| 33 void RunTest(const std::string& test_case); |
| 34 // Run the test and reload. This can test for clean shutdown, including leaked |
| 35 // instance object vars. |
| 36 void RunTestAndReload(const std::string& test_case); |
| 37 void RunTestViaHTTP(const std::string& test_case); |
| 38 void RunTestWithSSLServer(const std::string& test_case); |
| 39 void RunTestWithWebSocketServer(const std::string& test_case); |
| 40 void RunTestIfAudioOutputAvailable(const std::string& test_case); |
| 41 void RunTestViaHTTPIfAudioOutputAvailable(const std::string& test_case); |
| 42 std::string StripPrefixes(const std::string& test_name); |
| 43 |
| 44 protected: |
| 45 class TestFinishObserver : public content::NotificationObserver { |
| 46 public: |
| 47 TestFinishObserver(content::RenderViewHost* render_view_host, |
| 48 int timeout_s); |
| 49 |
| 50 bool WaitForFinish(); |
| 51 |
| 52 virtual void Observe(int type, |
| 53 const content::NotificationSource& source, |
| 54 const content::NotificationDetails& details) OVERRIDE; |
| 55 |
| 56 std::string result() const { return result_; } |
| 57 |
| 58 void Reset(); |
| 59 |
| 60 private: |
| 61 void OnTimeout(); |
| 62 |
| 63 bool finished_; |
| 64 bool waiting_; |
| 65 int timeout_s_; |
| 66 std::string result_; |
| 67 content::NotificationRegistrar registrar_; |
| 68 base::RepeatingTimer<TestFinishObserver> timer_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(TestFinishObserver); |
| 71 }; |
| 72 |
| 73 // Runs the test for a tab given the tab that's already navigated to the |
| 74 // given URL. |
| 75 void RunTestURL(const GURL& test_url); |
| 76 // Run the given |test_case| on a HTTP test server whose document root is |
| 77 // specified by |document_root|. |extra_params| will be passed as URL |
| 78 // parameters to the test. |
| 79 void RunHTTPTestServer(const FilePath& document_root, |
| 80 const std::string& test_case, |
| 81 const std::string& extra_params); |
| 82 // Return the document root for the HTTP server on which tests will be run. |
| 83 // The result is placed in |document_root|. False is returned upon failure. |
| 84 bool GetHTTPDocumentRoot(FilePath* document_root); |
| 85 }; |
| 86 |
| 87 // In-process plugin test runner. See OutOfProcessPPAPITest below for the |
| 88 // out-of-process version. |
| 89 class PPAPITest : public PPAPITestBase { |
| 90 public: |
| 91 PPAPITest(); |
| 92 |
| 93 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 94 |
| 95 virtual std::string BuildQuery(const std::string& base, |
| 96 const std::string& test_case) OVERRIDE; |
| 97 }; |
| 98 |
| 99 // Variant of PPAPITest that runs plugins out-of-process to test proxy |
| 100 // codepaths. |
| 101 class OutOfProcessPPAPITest : public PPAPITest { |
| 102 public: |
| 103 OutOfProcessPPAPITest(); |
| 104 |
| 105 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 106 }; |
| 107 |
| 108 // NaCl plugin test runner for Newlib runtime. |
| 109 class PPAPINaClTest : public PPAPITestBase { |
| 110 public: |
| 111 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 112 }; |
| 113 |
| 114 // NaCl plugin test runner for Newlib runtime. |
| 115 class PPAPINaClNewlibTest : public PPAPINaClTest { |
| 116 public: |
| 117 virtual std::string BuildQuery(const std::string& base, |
| 118 const std::string& test_case) OVERRIDE; |
| 119 }; |
| 120 |
| 121 // NaCl plugin test runner for GNU-libc runtime. |
| 122 class PPAPINaClGLibcTest : public PPAPINaClTest { |
| 123 public: |
| 124 virtual std::string BuildQuery(const std::string& base, |
| 125 const std::string& test_case) OVERRIDE; |
| 126 }; |
| 127 |
| 128 class PPAPINaClTestDisallowedSockets : public PPAPITestBase { |
| 129 public: |
| 130 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 131 |
| 132 virtual std::string BuildQuery(const std::string& base, |
| 133 const std::string& test_case) OVERRIDE; |
| 134 }; |
| 135 |
| 136 #endif // CHROME_TEST_PPAPI_PPAPI_TEST_H_ |
| OLD | NEW |