Sha256: 45f2c8d01e466d456965764165e71a5adb0de6e6f3fa1a24117fc444c07e1460

Contents?: true

Size: 878 Bytes

Versions: 25

Compression:

Stored size: 878 Bytes

Contents

#include <QtTest/QtTest>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include "../src/IgnoreDebugOutput.h"

#define MAX_LEN 40

class TestIgnoreDebugOutput: public QObject {
  Q_OBJECT

  private slots:
    void testIgnoreDebugOutput();
};

void TestIgnoreDebugOutput::testIgnoreDebugOutput() {
  char buffer[MAX_LEN+1] = {0};
  int out_pipe[2];
  int saved_stdout;

  saved_stdout = dup(STDOUT_FILENO);

  QVERIFY(pipe(out_pipe) == 0);

  dup2(out_pipe[1], STDOUT_FILENO);
  close(out_pipe[1]);

  long flags = fcntl(out_pipe[0], F_GETFL);
  flags |= O_NONBLOCK;
  fcntl(out_pipe[0], F_SETFL, flags);

  ignoreDebugOutput();

  qDebug() << "Message";
  fflush(stdout);

  read(out_pipe[0], buffer, MAX_LEN);

  dup2(saved_stdout, STDOUT_FILENO);

  QCOMPARE(QString(buffer), QString(""));
}

QTEST_MAIN(TestIgnoreDebugOutput)
#include "testignoredebugoutput.moc"

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
capybara-webkit-1.15.1 test/testignoredebugoutput.cpp
capybara-webkit-1.15.0 test/testignoredebugoutput.cpp
capybara-webkit-1.14.0 test/testignoredebugoutput.cpp
capybara-webkit-1.13.0 test/testignoredebugoutput.cpp
capybara-webkit-1.12.0 test/testignoredebugoutput.cpp
capybara-webkit-1.11.1 test/testignoredebugoutput.cpp
capybara-webkit-1.11.0 test/testignoredebugoutput.cpp
capybara-webkit-1.10.1 test/testignoredebugoutput.cpp
capybara-webkit-1.10.0 test/testignoredebugoutput.cpp
capybara-webkit-1.9.0 test/testignoredebugoutput.cpp
capybara-webkit-1.8.0 test/testignoredebugoutput.cpp
capybara-webkit-1.7.1 test/testignoredebugoutput.cpp
capybara-webkit-1.7.0 test/testignoredebugoutput.cpp
capybara-webkit-1.6.0 test/testignoredebugoutput.cpp
capybara-webkit-1.5.2 test/testignoredebugoutput.cpp
capybara-webkit-1.5.1 test/testignoredebugoutput.cpp
capybara-webkit-1.5.0 test/testignoredebugoutput.cpp
capybara-webkit-1.4.1 test/testignoredebugoutput.cpp
capybara-webkit-1.4.0 test/testignoredebugoutput.cpp
capybara-webkit-1.3.1 test/testignoredebugoutput.cpp