From 4bf7ca2fd00ac20b5c9b0c7fe08840057bf99487 Mon Sep 17 00:00:00 2001 From: "dmichael@chromium.org" Date: Fri, 8 Nov 2013 05:20:52 +0000 Subject: PPAPI: Add a test to make sure we detect crashes And bonus check that other tests *don't* crash. (Though it should be very rare that a test results in "PASS" and still crashes) Earlier patchsets have a fix for 244900, but we decided not to fix that. Because of 244900, we don't detect crashes on shutdown... so this doesn't actually cause test failures for 243118. But it's useful to make sure we don't regress on showing the infobar in crashes that happen prior to shutdown. BUG=244900,243118,247128 Review URL: https://codereview.chromium.org/16114007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233768 0039d316-1c4b-4281-b951-d872f2087c98 --- ppapi/ppapi_sources.gypi | 2 ++ ppapi/tests/test_crash.cc | 26 ++++++++++++++++++++++++++ ppapi/tests/test_crash.h | 25 +++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 ppapi/tests/test_crash.cc create mode 100644 ppapi/tests/test_crash.h (limited to 'ppapi') diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index 52d8e00..d35ff84 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -409,6 +409,8 @@ 'tests/test_console.h', 'tests/test_core.cc', 'tests/test_core.h', + 'tests/test_crash.cc', + 'tests/test_crash.h', 'tests/test_cursor_control.cc', 'tests/test_cursor_control.h', 'tests/test_empty.cc', diff --git a/ppapi/tests/test_crash.cc b/ppapi/tests/test_crash.cc new file mode 100644 index 0000000..22f7772 --- /dev/null +++ b/ppapi/tests/test_crash.cc @@ -0,0 +1,26 @@ +// Copyright 2013 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. + +#include + +#include "ppapi/tests/test_crash.h" +#include "ppapi/tests/testing_instance.h" + +REGISTER_TEST_CASE(Crash); + +TestCrash::TestCrash(TestingInstance* instance) + : TestCase(instance) { +} + +void TestCrash::RunTests(const std::string& filter) { + RUN_TEST(CrashInCallOnMainThread, filter); +} + +std::string TestCrash::TestCrashInCallOnMainThread() { + // The tests are run via CallOnMainThread (see DidChangeView in + // TestingInstance), so we just crash here. + abort(); + PASS(); +} + diff --git a/ppapi/tests/test_crash.h b/ppapi/tests/test_crash.h new file mode 100644 index 0000000..ed6af8c --- /dev/null +++ b/ppapi/tests/test_crash.h @@ -0,0 +1,25 @@ +// Copyright 2013 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 PPAPI_TESTS_TEST_CRASH_H_ +#define PPAPI_TESTS_TEST_CRASH_H_ + +#include + +#include "ppapi/tests/test_case.h" + +// This test crashes at different points, allowing us to make sure the browser +// detects the crashes. +class TestCrash : public TestCase { + public: + explicit TestCrash(TestingInstance* instance); + + private: + // TestCase implementation. + virtual void RunTests(const std::string& filter); + + std::string TestCrashInCallOnMainThread(); +}; + +#endif // PPAPI_TESTS_TEST_CRASH_H_ -- cgit v1.1