summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ppapi/tests/test_case.cc13
-rw-r--r--ppapi/tests/test_case.h10
-rw-r--r--ppapi/tests/test_graphics_2d.h3
-rw-r--r--ppapi/tests/test_post_message.cc11
-rw-r--r--ppapi/tests/test_post_message.h7
-rw-r--r--ppapi/tests/test_url_loader.cc2
-rw-r--r--ppapi/tests/test_var_deprecated.cc13
-rw-r--r--ppapi/tests/test_var_deprecated.h4
-rw-r--r--ppapi/tests/test_video_decoder.cc11
-rw-r--r--ppapi/tests/test_video_decoder.h2
10 files changed, 26 insertions, 50 deletions
diff --git a/ppapi/tests/test_case.cc b/ppapi/tests/test_case.cc
index bfcfa8c..ec9f088 100644
--- a/ppapi/tests/test_case.cc
+++ b/ppapi/tests/test_case.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -9,6 +9,14 @@
#include "ppapi/tests/test_utils.h"
#include "ppapi/tests/testing_instance.h"
+TestCase::TestCase(TestingInstance* instance)
+ : instance_(instance),
+ testing_interface_(NULL) {
+}
+
+TestCase::~TestCase() {
+}
+
// static
std::string TestCase::MakeFailureMessage(const char* file,
int line,
@@ -42,7 +50,8 @@ pp::deprecated::ScriptableObject* TestCase::CreateTestObject() {
}
bool TestCase::InitTestingInterface() {
- if (!GetTestingInterface()) {
+ testing_interface_ = GetTestingInterface();
+ if (!testing_interface_) {
// Give a more helpful error message for the testing interface being gone
// since that needs special enabling in Chrome.
instance_->AppendError("This test needs the testing interface, which is "
diff --git a/ppapi/tests/test_case.h b/ppapi/tests/test_case.h
index 9ccde68..5e77d0d 100644
--- a/ppapi/tests/test_case.h
+++ b/ppapi/tests/test_case.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -13,6 +13,7 @@
#include "ppapi/cpp/dev/scrollbar_dev.h"
#include "ppapi/cpp/var.h"
+struct PPB_Testing_Dev;
class TestingInstance;
namespace pp {
@@ -24,8 +25,8 @@ class ScriptableObject;
// Individual classes of tests derive from this generic test case.
class TestCase {
public:
- explicit TestCase(TestingInstance* instance) : instance_(instance) {}
- virtual ~TestCase() {}
+ explicit TestCase(TestingInstance* instance);
+ virtual ~TestCase();
// Optionally override to do testcase specific initialization.
virtual bool Init() { return true; }
@@ -65,6 +66,9 @@ class TestCase {
// Pointer to the instance that owns us.
TestingInstance* instance_;
+ // NULL unless InitTestingInterface is called.
+ const PPB_Testing_Dev* testing_interface_;
+
private:
// Holds the test object, if any was retrieved from CreateTestObject.
pp::Var test_object_;
diff --git a/ppapi/tests/test_graphics_2d.h b/ppapi/tests/test_graphics_2d.h
index a82207f..95ba7ef 100644
--- a/ppapi/tests/test_graphics_2d.h
+++ b/ppapi/tests/test_graphics_2d.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -82,7 +82,6 @@ class TestGraphics2D : public TestCase {
// Used by the tests that access the C API directly.
const PPB_Graphics2D* graphics_2d_interface_;
const PPB_ImageData* image_data_interface_;
- const PPB_Testing_Dev* testing_interface_;
};
#endif // PAPPI_TESTS_TEST_GRAPHICS_2D_H_
diff --git a/ppapi/tests/test_post_message.cc b/ppapi/tests/test_post_message.cc
index 644b3cbf..abe1733 100644
--- a/ppapi/tests/test_post_message.cc
+++ b/ppapi/tests/test_post_message.cc
@@ -24,16 +24,7 @@ const int32_t kThreadsToRun = 10;
} // namespace
bool TestPostMessage::Init() {
- testing_interface_ = reinterpret_cast<const PPB_Testing_Dev*>(
- pp::Module::Get()->GetBrowserInterface(PPB_TESTING_DEV_INTERFACE));
- if (!testing_interface_) {
- // Give a more helpful error message for the testing interface being gone
- // since that needs special enabling in Chrome.
- instance_->AppendError("This test needs the testing interface, which is "
- "not currently available. In Chrome, use --enable-pepper-testing when "
- "launching.");
- }
- return (testing_interface_ != NULL);
+ return InitTestingInterface();
}
void TestPostMessage::RunTest() {
diff --git a/ppapi/tests/test_post_message.h b/ppapi/tests/test_post_message.h
index 1b841c8..cf347ec 100644
--- a/ppapi/tests/test_post_message.h
+++ b/ppapi/tests/test_post_message.h
@@ -10,12 +10,9 @@
#include "ppapi/tests/test_case.h"
-struct PPB_Testing_Dev;
-
class TestPostMessage : public TestCase {
public:
- explicit TestPostMessage(TestingInstance* instance)
- : TestCase(instance), testing_interface_(NULL) {}
+ explicit TestPostMessage(TestingInstance* instance) : TestCase(instance) {}
private:
// TestCase implementation.
@@ -42,8 +39,6 @@ class TestPostMessage : public TestCase {
// Test sending a message when no handler exists, make sure nothing happens.
std::string TestNoHandler();
- const PPB_Testing_Dev* testing_interface_;
-
// This is used to store pp::Var objects we receive via a call to
// HandleMessage.
std::vector<pp::Var> message_data_;
diff --git a/ppapi/tests/test_url_loader.cc b/ppapi/tests/test_url_loader.cc
index 6a4d62e..55bd851 100644
--- a/ppapi/tests/test_url_loader.cc
+++ b/ppapi/tests/test_url_loader.cc
@@ -222,7 +222,7 @@ std::string TestURLLoader::TestStreamToFile() {
return ReportError("URLLoader::FinishStreamingToFile", rv);
- pp::FileIO_Dev reader;
+ pp::FileIO_Dev reader(instance_);
rv = reader.Open(body, PP_FILEOPENFLAG_READ, callback);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
diff --git a/ppapi/tests/test_var_deprecated.cc b/ppapi/tests/test_var_deprecated.cc
index c8e960d..7b77b18 100644
--- a/ppapi/tests/test_var_deprecated.cc
+++ b/ppapi/tests/test_var_deprecated.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -69,16 +69,7 @@ REGISTER_TEST_CASE(VarDeprecated);
bool TestVarDeprecated::Init() {
var_interface_ = reinterpret_cast<PPB_Var_Deprecated const*>(
pp::Module::Get()->GetBrowserInterface(PPB_VAR_DEPRECATED_INTERFACE));
- testing_interface_ = reinterpret_cast<PPB_Testing_Dev const*>(
- pp::Module::Get()->GetBrowserInterface(PPB_TESTING_DEV_INTERFACE));
- if (!testing_interface_) {
- // Give a more helpful error message for the testing interface being gone
- // since that needs special enabling in Chrome.
- instance_->AppendError("This test needs the testing interface, which is "
- "not currently available. In Chrome, use --enable-pepper-testing when "
- "launching.");
- }
- return var_interface_ && testing_interface_;
+ return var_interface_ && InitTestingInterface();
}
void TestVarDeprecated::RunTest() {
diff --git a/ppapi/tests/test_var_deprecated.h b/ppapi/tests/test_var_deprecated.h
index 75efd736..faed7be 100644
--- a/ppapi/tests/test_var_deprecated.h
+++ b/ppapi/tests/test_var_deprecated.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -10,7 +10,6 @@
#include "ppapi/cpp/var.h"
#include "ppapi/tests/test_case.h"
-struct PPB_Testing_Dev;
struct PPB_Var_Deprecated;
class TestVarDeprecated : public TestCase {
@@ -40,7 +39,6 @@ class TestVarDeprecated : public TestCase {
// Used by the tests that access the C API directly.
const PPB_Var_Deprecated* var_interface_;
- const PPB_Testing_Dev* testing_interface_;
// Saves the var from when a value is set on the test from the page.
pp::Var var_from_page_;
diff --git a/ppapi/tests/test_video_decoder.cc b/ppapi/tests/test_video_decoder.cc
index f669d47..4279894 100644
--- a/ppapi/tests/test_video_decoder.cc
+++ b/ppapi/tests/test_video_decoder.cc
@@ -16,16 +16,7 @@ bool TestVideoDecoder::Init() {
pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_DEV_INTERFACE));
var_interface_ = reinterpret_cast<PPB_Var const*>(
pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE));
- testing_interface_ = reinterpret_cast<PPB_Testing_Dev const*>(
- pp::Module::Get()->GetBrowserInterface(PPB_TESTING_DEV_INTERFACE));
- if (!testing_interface_) {
- // Give a more helpful error message for the testing interface being gone
- // since that needs special enabling in Chrome.
- instance_->AppendError("This test needs the testing interface, which is "
- "not currently available. In Chrome, use --enable-pepper-testing when "
- "launching.");
- }
- return video_decoder_interface_ && var_interface_ && testing_interface_;
+ return video_decoder_interface_ && var_interface_ && InitTestingInterface();
}
void TestVideoDecoder::RunTest() {
diff --git a/ppapi/tests/test_video_decoder.h b/ppapi/tests/test_video_decoder.h
index 7c852b7..15e0b39 100644
--- a/ppapi/tests/test_video_decoder.h
+++ b/ppapi/tests/test_video_decoder.h
@@ -8,7 +8,6 @@
#include "ppapi/c/pp_stdint.h"
#include "ppapi/tests/test_case.h"
-struct PPB_Testing_Dev;
struct PPB_Var;
struct PPB_VideoDecoder_Dev;
@@ -28,7 +27,6 @@ class TestVideoDecoder : public TestCase {
// Used by the tests that access the C API directly.
const PPB_VideoDecoder_Dev* video_decoder_interface_;
const PPB_Var* var_interface_;
- const PPB_Testing_Dev* testing_interface_;
};
#endif // PPAPI_TESTS_TEST_VIDEO_DECODER_H_