Beispiel #1
0
static void runTest(TestShell& shell, TestParams& params, const string& testName, bool testShellMode)
{
    int oldTimeoutMsec = shell.layoutTestTimeout();
    params.pixelHash = "";
    string pathOrURL = testName;
    if (testShellMode) {
        string timeOut;
        string::size_type separatorPosition = pathOrURL.find(' ');
        if (separatorPosition != string::npos) {
            timeOut = pathOrURL.substr(separatorPosition + 1);
            pathOrURL.erase(separatorPosition);
            separatorPosition = timeOut.find_first_of(' ');
            if (separatorPosition != string::npos) {
                params.pixelHash = timeOut.substr(separatorPosition + 1);
                timeOut.erase(separatorPosition);
            }
            shell.setLayoutTestTimeout(atoi(timeOut.c_str()));
        }
    } else {
        string::size_type separatorPosition = pathOrURL.find("'");
        if (separatorPosition != string::npos) {
            params.pixelHash = pathOrURL.substr(separatorPosition + 1);
            pathOrURL.erase(separatorPosition);
        }
    }
    params.testUrl = webkit_support::CreateURLForPathOrURL(pathOrURL);
    webkit_support::SetCurrentDirectoryForFileURL(params.testUrl);
    shell.resetTestController();
    shell.runFileTest(params);
    shell.setLayoutTestTimeout(oldTimeoutMsec);
}
Beispiel #2
0
int main(int argc, char* argv[])
{
    webkit_support::SetUpTestEnvironment();
    platformInit();

    TestParams params;
    Vector<string> tests;
    bool serverMode = false;
    for (int i = 1; i < argc; ++i) {
        string argument(argv[i]);
        if (argument == "-")
            serverMode = true;
        else if (argument == optionNotree)
            params.dumpTree = false;
        else if (argument == optionPixelTests)
            params.dumpPixels = true;
        else if (argument.size() && argument[0] == '-')
            fprintf(stderr, "Unknown option: %s\n", argv[i]);
        else
            tests.append(argument);
    }

    { // Explicit scope for the TestShell instance.
        TestShell shell;
        if (serverMode && !tests.size()) {
            params.printSeparators = true;
            char testString[2048]; // 2048 is the same as the sizes of other platforms.
            while (fgets(testString, sizeof(testString), stdin)) {
                char* newLinePosition = strchr(testString, '\n');
                if (newLinePosition)
                    *newLinePosition = '\0';
                if (testString[0] == '\0')
                    continue;
                runTest(shell, params, testString);
            }
        } else if (!tests.size())
            printf("#EOF\n");
        else {
            params.printSeparators = tests.size() > 1;
            for (unsigned i = 0; i < tests.size(); i++)
                runTest(shell, params, tests[i]);
        }

        shell.callJSGC();
        shell.callJSGC();

        // When we finish the last test, cleanup the LayoutTestController.
        // It may have references to not-yet-cleaned up windows.  By
        // cleaning up here we help purify reports.
        shell.resetTestController();
    }

    webkit_support::TearDownTestEnvironment();
    return EXIT_SUCCESS;
}
Beispiel #3
0
static void runTest(TestShell& shell, TestParams& params, const string& testName)
{
    string pathOrURL = testName;
    string::size_type separatorPosition = pathOrURL.find("'");
    if (separatorPosition != string::npos) {
        params.pixelHash = pathOrURL.substr(separatorPosition + 1);
        pathOrURL.erase(separatorPosition);
    }
    params.testUrl = webkit_support::CreateURLForPathOrURL(pathOrURL);
    shell.resetTestController();
    shell.runFileTest(params);
}
void LayoutTestController::WorkQueue::processWork()
{
    TestShell* shell = m_controller->m_shell;
    // Quit doing work once a load is in progress.
    while (!m_queue.isEmpty()) {
        bool startedLoad = m_queue.first()->run(shell);
        delete m_queue.first();
        m_queue.removeFirst();
        if (startedLoad)
            return;
    }

    if (!m_controller->m_waitUntilDone && !shell->webViewHost()->topLoadingFrame())
        shell->testFinished();
}
Beispiel #5
0
void WebViewHost::runModal()
{
    if (m_shell->isDisplayingModalDialog()) {
        // DumpRenderTree doesn't support real modal dialogs, so a test shouldn't try to start two modal dialogs at the same time.
        ASSERT_NOT_REACHED();
        return;
    }
    // This WebViewHost might get deleted before RunMessageLoop() returns, so keep a copy of the m_shell member variable around.
    ASSERT(m_shell->webViewHost() != this);
    TestShell* shell = m_shell;
    shell->setIsDisplayingModalDialog(true);
    bool oldState = webkit_support::MessageLoopNestableTasksAllowed();
    webkit_support::MessageLoopSetNestableTasksAllowed(true);
    m_inModalLoop = true;
    webkit_support::RunMessageLoop();
    webkit_support::MessageLoopSetNestableTasksAllowed(oldState);
    shell->setIsDisplayingModalDialog(false);
}
Beispiel #6
0
// Thread main to run for the thread which just tests for timeout.
unsigned int __stdcall watchDogThread(void *arg)
{
    // If we're debugging a layout test, don't timeout.
    if (::IsDebuggerPresent())
    return 0;

    TestShell* shell = static_cast<TestShell*>(arg);
    // FIXME: Do we need user-specified time settings as with the original
    // Chromium implementation?
    DWORD timeout = static_cast<DWORD>(kDefaultWatchDogTimeoutMillisecs);
    DWORD rv = WaitForSingleObject(shell->finishedEvent(), timeout);
    if (rv == WAIT_TIMEOUT) {
        // Print a warning to be caught by the layout-test script.
        // Note: the layout test driver may or may not recognize
        // this as a timeout.
        puts("#TEST_TIMED_OUT\n");
        puts("#EOF\n");
        fflush(stdout);
        TerminateProcess(GetCurrentProcess(), 0);
    }
    // Finished normally.
    return 0;
}
Beispiel #7
0
static void runTest(TestShell& shell, TestParams& params, const string& inputLine, const bool forceDumpPixels)
{
    int oldTimeoutMsec = shell.layoutTestTimeout();
    TestCommand command = parseInputLine(inputLine);
    params.testUrl = webkit_support::CreateURLForPathOrURL(command.pathOrURL);
    params.pixelHash = command.shouldDumpPixels;
    webkit_support::SetCurrentDirectoryForFileURL(params.testUrl);
    v8::V8::SetFlagsFromString(shell.javaScriptFlags().c_str(), shell.javaScriptFlags().length());
    if (shell.stressOpt() || shell.stressDeopt()) {
      if (shell.stressOpt())
        v8::Testing::SetStressRunType(v8::Testing::kStressTypeOpt);
      else
        v8::Testing::SetStressRunType(v8::Testing::kStressTypeDeopt);
      for (int i = 0; i < v8::Testing::GetStressRuns(); i++) {
          v8::Testing::PrepareStressRun(i);
          bool isLastLoad = (i == (v8::Testing::GetStressRuns() - 1));
          shell.setDumpWhenFinished(isLastLoad);
          shell.resetTestController();
          shell.runFileTest(params, command.shouldDumpPixels || forceDumpPixels);
      }
    } else {
      shell.resetTestController();
      shell.runFileTest(params, command.shouldDumpPixels || forceDumpPixels);
    }
    shell.setLayoutTestTimeout(oldTimeoutMsec);
}
Beispiel #8
0
int main(int argc, char* argv[])
{
    WebKitSupportTestEnvironment testEnvironment;
    platformInit(&argc, &argv);

    TestParams params;
    Vector<string> tests;
    bool serverMode = false;
    bool dumpAllPixels = false;
    bool allowExternalPages = false;
    bool startupDialog = false;
    bool acceleratedCompositingForVideoEnabled = false;
    bool acceleratedCompositingForFixedPositionEnabled = false;
    bool acceleratedCompositingForOverflowScrollEnabled = false;
    bool acceleratedCompositingForTransitionEnabled = false;
    bool softwareCompositingEnabled = false;
    bool threadedCompositingEnabled = false;
    bool forceCompositingMode = false;
    bool threadedHTMLParser = true;
    bool accelerated2DCanvasEnabled = false;
    bool perTilePaintingEnabled = false;
    bool deferredImageDecodingEnabled = false;
    bool stressOpt = false;
    bool stressDeopt = false;
    bool hardwareAcceleratedGL = false;
    string javaScriptFlags;
    bool encodeBinary = false;
    bool noTimeout = false;
    for (int i = 1; i < argc; ++i) {
        string argument(argv[i]);
        if (argument == "-")
            serverMode = true;
        else if (argument == optionDumpPixels || argument == optionDumpPixelsShortForm)
            dumpAllPixels = true;
        else if (argument == optionNotree)
            params.dumpTree = false;
        else if (argument == optionDebugRenderTree)
            params.debugRenderTree = true;
        else if (argument == optionDebugLayerTree)
            params.debugLayerTree = true;
        else if (argument == optionAllowExternalPages)
            allowExternalPages = true;
        else if (argument == optionStartupDialog)
            startupDialog = true;
        else if (argument == optionCheckLayoutTestSystemDeps)
            return checkLayoutTestSystemDependencies() ? EXIT_SUCCESS : EXIT_FAILURE;
        else if (argument == optionHardwareAcceleratedGL)
            hardwareAcceleratedGL = true;
        else if (argument == optionEnableAcceleratedCompositingForVideo)
            acceleratedCompositingForVideoEnabled = true;
        else if (argument == optionEnableAcceleratedFixedPosition)
            acceleratedCompositingForFixedPositionEnabled = true;
        else if (argument == optionEnableAcceleratedOverflowScroll)
            acceleratedCompositingForOverflowScrollEnabled = true;
        else if (argument == optionEnableAcceleratedTransition)
            acceleratedCompositingForTransitionEnabled = true;
        else if (argument == optionEnableSoftwareCompositing)
            softwareCompositingEnabled = true;
        else if (argument == optionEnableThreadedCompositing)
            threadedCompositingEnabled = true;
        else if (argument == optionForceCompositingMode)
            forceCompositingMode = true;
        else if (argument == optionDisableThreadedHTMLParser)
            threadedHTMLParser = false;
        else if (argument == optionEnableAccelerated2DCanvas)
            accelerated2DCanvasEnabled = true;
        else if (argument == optionEnablePerTilePainting)
            perTilePaintingEnabled = true;
        else if (argument == optionEnableDeferredImageDecoding)
            deferredImageDecodingEnabled = true;
        else if (argument == optionStressOpt)
            stressOpt = true;
        else if (argument == optionStressDeopt)
            stressDeopt = true;
        else if (!argument.find(optionJavaScriptFlags))
            javaScriptFlags = argument.substr(strlen(optionJavaScriptFlags));
        else if (argument == optionEncodeBinary)
            encodeBinary = true;
        else if (argument == optionNoTimeout)
            noTimeout = true;
        else if (!argument.find(optionWebCoreLogChannels)) {
            string channels = argument.substr(strlen(optionWebCoreLogChannels));
            webkit_support::EnableWebCoreLogChannels(channels);
        } else if (argument.size() && argument[0] == '-')
            fprintf(stderr, "Unknown option: %s\n", argv[i]);
        else
            tests.append(argument);
    }
    if (stressOpt && stressDeopt) {
        fprintf(stderr, "--stress-opt and --stress-deopt are mutually exclusive.\n");
        return EXIT_FAILURE;
    }

    webkit_support::SetUpGLBindings(hardwareAcceleratedGL ? webkit_support::GL_BINDING_DEFAULT : webkit_support::GL_BINDING_SOFTWARE_RENDERER);

    if (startupDialog)
        openStartupDialog();

    { // Explicit scope for the TestShell instance.
        TestShell shell;
        shell.setAllowExternalPages(allowExternalPages);
        shell.setAcceleratedCompositingForVideoEnabled(acceleratedCompositingForVideoEnabled);
        shell.setAcceleratedCompositingForFixedPositionEnabled(acceleratedCompositingForFixedPositionEnabled);
        shell.setAcceleratedCompositingForOverflowScrollEnabled(acceleratedCompositingForOverflowScrollEnabled);
        shell.setAcceleratedCompositingForTransitionEnabled(acceleratedCompositingForTransitionEnabled);
        shell.setSoftwareCompositingEnabled(softwareCompositingEnabled);
        shell.setThreadedCompositingEnabled(threadedCompositingEnabled);
        shell.setForceCompositingMode(forceCompositingMode);
        shell.setThreadedHTMLParser(threadedHTMLParser);
        shell.setAccelerated2dCanvasEnabled(accelerated2DCanvasEnabled);
        shell.setPerTilePaintingEnabled(perTilePaintingEnabled);
        shell.setDeferredImageDecodingEnabled(deferredImageDecodingEnabled);
        shell.setJavaScriptFlags(javaScriptFlags);
        shell.setStressOpt(stressOpt);
        shell.setStressDeopt(stressDeopt);
        shell.setEncodeBinary(encodeBinary);
        if (noTimeout) {
            // 0x20000000ms is big enough for the purpose to avoid timeout in debugging.
            shell.setLayoutTestTimeout(0x20000000);
        }
        shell.initialize(testEnvironment.mockPlatform());
        if (serverMode && !tests.size()) {
#if OS(ANDROID)
            // Send a signal to host to indicate DRT is ready to process commands.
            puts("#READY");
            fflush(stdout);
#endif
            params.printSeparators = true;
            char testString[2048]; // 2048 is the same as the sizes of other platforms.
            while (fgets(testString, sizeof(testString), stdin)) {
                char* newLinePosition = strchr(testString, '\n');
                if (newLinePosition)
                    *newLinePosition = '\0';
                if (testString[0] == '\0')
                    continue;
                // Explicitly quit on platforms where EOF is not reliable.
                if (!strcmp(testString, "QUIT"))
                    break;
                runTest(shell, params, testString, dumpAllPixels);
            }
        } else if (!tests.size())
            puts("#EOF");
        else {
            params.printSeparators = tests.size() > 1;
            for (unsigned i = 0; i < tests.size(); i++)
                runTest(shell, params, tests[i], dumpAllPixels);
        }

        shell.callJSGC();
        shell.callJSGC();

        // When we finish the last test, cleanup the DRTTestRunner.
        // It may have references to not-yet-cleaned up windows. By cleaning up
        // here we help purify reports.
        shell.resetTestController();
    }

    return EXIT_SUCCESS;
}
Beispiel #9
0
static void runTest(TestShell& shell, TestParams& params, const string& testName, bool testShellMode)
{
    int oldTimeoutMsec = shell.layoutTestTimeout();
    params.pixelHash = "";
    string pathOrURL = testName;
    if (testShellMode) {
        string timeOut;
        string::size_type separatorPosition = pathOrURL.find(' ');
        if (separatorPosition != string::npos) {
            timeOut = pathOrURL.substr(separatorPosition + 1);
            pathOrURL.erase(separatorPosition);
            separatorPosition = timeOut.find_first_of(' ');
            if (separatorPosition != string::npos) {
                params.pixelHash = timeOut.substr(separatorPosition + 1);
                timeOut.erase(separatorPosition);
            }
            shell.setLayoutTestTimeout(atoi(timeOut.c_str()));
        }
    } else {
        string::size_type separatorPosition = pathOrURL.find("'");
        if (separatorPosition != string::npos) {
            params.pixelHash = pathOrURL.substr(separatorPosition + 1);
            pathOrURL.erase(separatorPosition);
        }
    }
    params.testUrl = webkit_support::CreateURLForPathOrURL(pathOrURL);
    webkit_support::SetCurrentDirectoryForFileURL(params.testUrl);
    v8::V8::SetFlagsFromString(shell.javaScriptFlags().c_str(), shell.javaScriptFlags().length());
    if (shell.stressOpt() || shell.stressDeopt()) {
      if (shell.stressOpt())
        v8::Testing::SetStressRunType(v8::Testing::kStressTypeOpt);
      else
        v8::Testing::SetStressRunType(v8::Testing::kStressTypeDeopt);
      for (int i = 0; i < v8::Testing::GetStressRuns(); i++) {
          v8::Testing::PrepareStressRun(i);
          bool isLastLoad = (i == (v8::Testing::GetStressRuns() - 1));
          shell.setDumpWhenFinished(isLastLoad);
          shell.resetTestController();
          shell.runFileTest(params);
      }
    } else {
      shell.resetTestController();
      shell.runFileTest(params);
    }
    shell.setLayoutTestTimeout(oldTimeoutMsec);
}