| 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_UI_PPAPI_UITEST_H_ | 5 #ifndef CHROME_TEST_PPAPI_PPAPI_TEST_H_ |
| 6 #define CHROME_TEST_UI_PPAPI_UITEST_H_ | 6 #define CHROME_TEST_PPAPI_PPAPI_TEST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 13 #include "base/timer.h" |
| 11 #include "chrome/test/base/in_process_browser_test.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 } |
| 12 | 21 |
| 13 class PPAPITestBase : public InProcessBrowserTest { | 22 class PPAPITestBase : public InProcessBrowserTest { |
| 14 public: | 23 public: |
| 15 PPAPITestBase(); | 24 PPAPITestBase(); |
| 16 | 25 |
| 17 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 26 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 18 | 27 |
| 19 virtual std::string BuildQuery(const std::string& base, | 28 virtual std::string BuildQuery(const std::string& base, |
| 20 const std::string& test_case) = 0; | 29 const std::string& test_case) = 0; |
| 21 | 30 |
| 22 // Returns the URL to load for file: tests. | 31 // Returns the URL to load for file: tests. |
| 23 GURL GetTestFileUrl(const std::string& test_case); | 32 GURL GetTestFileUrl(const std::string& test_case); |
| 24 void RunTest(const std::string& test_case); | 33 void RunTest(const std::string& test_case); |
| 25 // Run the test and reload. This can test for clean shutdown, including leaked | 34 // Run the test and reload. This can test for clean shutdown, including leaked |
| 26 // instance object vars. | 35 // instance object vars. |
| 27 void RunTestAndReload(const std::string& test_case); | 36 void RunTestAndReload(const std::string& test_case); |
| 28 void RunTestViaHTTP(const std::string& test_case); | 37 void RunTestViaHTTP(const std::string& test_case); |
| 29 void RunTestWithSSLServer(const std::string& test_case); | 38 void RunTestWithSSLServer(const std::string& test_case); |
| 30 void RunTestWithWebSocketServer(const std::string& test_case); | 39 void RunTestWithWebSocketServer(const std::string& test_case); |
| 31 void RunTestIfAudioOutputAvailable(const std::string& test_case); | 40 void RunTestIfAudioOutputAvailable(const std::string& test_case); |
| 32 void RunTestViaHTTPIfAudioOutputAvailable(const std::string& test_case); | 41 void RunTestViaHTTPIfAudioOutputAvailable(const std::string& test_case); |
| 33 std::string StripPrefixes(const std::string& test_name); | 42 std::string StripPrefixes(const std::string& test_name); |
| 34 | 43 |
| 35 protected: | 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 |
| 36 // Runs the test for a tab given the tab that's already navigated to the | 73 // Runs the test for a tab given the tab that's already navigated to the |
| 37 // given URL. | 74 // given URL. |
| 38 void RunTestURL(const GURL& test_url); | 75 void RunTestURL(const GURL& test_url); |
| 39 // Run the given |test_case| on a HTTP test server whose document root is | 76 // Run the given |test_case| on a HTTP test server whose document root is |
| 40 // specified by |document_root|. |extra_params| will be passed as URL | 77 // specified by |document_root|. |extra_params| will be passed as URL |
| 41 // parameters to the test. | 78 // parameters to the test. |
| 42 void RunHTTPTestServer(const FilePath& document_root, | 79 void RunHTTPTestServer(const FilePath& document_root, |
| 43 const std::string& test_case, | 80 const std::string& test_case, |
| 44 const std::string& extra_params); | 81 const std::string& extra_params); |
| 45 // Return the document root for the HTTP server on which tests will be run. | 82 // Return the document root for the HTTP server on which tests will be run. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 }; | 126 }; |
| 90 | 127 |
| 91 class PPAPINaClTestDisallowedSockets : public PPAPITestBase { | 128 class PPAPINaClTestDisallowedSockets : public PPAPITestBase { |
| 92 public: | 129 public: |
| 93 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 130 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 94 | 131 |
| 95 virtual std::string BuildQuery(const std::string& base, | 132 virtual std::string BuildQuery(const std::string& base, |
| 96 const std::string& test_case) OVERRIDE; | 133 const std::string& test_case) OVERRIDE; |
| 97 }; | 134 }; |
| 98 | 135 |
| 99 #endif // CHROME_TEST_UI_PPAPI_UITEST_H_ | 136 #endif // CHROME_TEST_PPAPI_PPAPI_TEST_H_ |
| OLD | NEW |