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