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; }