1 // Copyright (c) 2011 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 #include "ppapi/tests/test_case.h"
9 #include "ppapi/tests/test_utils.h"
10 #include "ppapi/tests/testing_instance.h"
12 TestCase::TestCase(TestingInstance
* instance
)
13 : instance_(instance
),
14 testing_interface_(NULL
),
18 TestCase::~TestCase() {
21 bool TestCase::Init() {
26 std::string
TestCase::MakeFailureMessage(const char* file
,
29 // The mere presence of this local variable works around a gcc-4.2.4
30 // compiler bug in official Chrome Linux builds. If you remove it,
31 // confirm this compile command still works:
32 // GYP_DEFINES='branding=Chrome buildtype=Official target_arch=x64'
34 // make -k -j4 BUILDTYPE=Release ppapi_tests
37 std::ostringstream output
;
38 output
<< "Failure in " << file
<< "(" << line
<< "): " << cmd
;
42 #if !(defined __native_client__)
43 pp::VarPrivate
TestCase::GetTestObject() {
44 if (test_object_
.is_undefined()) {
45 pp::deprecated::ScriptableObject
* so
= CreateTestObject();
47 test_object_
= pp::VarPrivate(instance_
, so
); // Takes ownership.
53 void TestCase::HandleMessage(const pp::Var
& message_data
) {
56 void TestCase::DidChangeView(const pp::Rect
& position
, const pp::Rect
& clip
) {
59 bool TestCase::HandleInputEvent(const pp::InputEvent
& event
) {
63 #if !(defined __native_client__)
64 pp::deprecated::ScriptableObject
* TestCase::CreateTestObject() {
69 bool TestCase::InitTestingInterface() {
70 testing_interface_
= GetTestingInterface();
71 if (!testing_interface_
) {
72 // Give a more helpful error message for the testing interface being gone
73 // since that needs special enabling in Chrome.
74 instance_
->AppendError("This test needs the testing interface, which is "
75 "not currently available. In Chrome, use "
76 "--enable-pepper-testing when launching.");
83 bool TestCase::EnsureRunningOverHTTP() {
84 if (instance_
->protocol() != "http:") {
85 instance_
->AppendError("This test needs to be run over HTTP.");
92 bool TestCase::MatchesFilter(const std::string
& test_name
,
93 const std::string
& filter
) {
94 return filter
.empty() || (test_name
== filter
);