Convert TestOldCompletionCallback in WebSocketJobTest.
[chromium-blink-merge.git] / ppapi / tests / test_case.cc
blobbcee6c3b73dc0af22253a9184f4123087ddacfc5
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"
7 #include <sstream>
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),
15 force_async_(false) {
18 TestCase::~TestCase() {
21 bool TestCase::Init() {
22 return true;
25 // static
26 std::string TestCase::MakeFailureMessage(const char* file,
27 int line,
28 const char* cmd) {
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'
33 // gclient runhooks
34 // make -k -j4 BUILDTYPE=Release ppapi_tests
35 std::string s;
37 std::ostringstream output;
38 output << "Failure in " << file << "(" << line << "): " << cmd;
39 return output.str();
42 #if !(defined __native_client__)
43 pp::VarPrivate TestCase::GetTestObject() {
44 if (test_object_.is_undefined()) {
45 pp::deprecated::ScriptableObject* so = CreateTestObject();
46 if (so)
47 test_object_ = pp::VarPrivate(instance_, so); // Takes ownership.
49 return test_object_;
51 #endif
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) {
60 return false;
63 #if !(defined __native_client__)
64 pp::deprecated::ScriptableObject* TestCase::CreateTestObject() {
65 return NULL;
67 #endif
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.");
77 return false;
80 return true;
83 bool TestCase::EnsureRunningOverHTTP() {
84 if (instance_->protocol() != "http:") {
85 instance_->AppendError("This test needs to be run over HTTP.");
86 return false;
89 return true;
92 bool TestCase::MatchesFilter(const std::string& test_name,
93 const std::string& filter) {
94 return filter.empty() || (test_name == filter);