Back to index

unity  6.0.0
Defines | Functions
test-get-transients.cpp File Reference
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <unistd.h>
#include <sstream>
#include <cstring>
#include <x11-window-read-transients.h>

Go to the source code of this file.

Defines

#define _GNU_SOURCE

Functions

void usage ()
int main (int argc, char **argv)

Define Documentation

#define _GNU_SOURCE

Definition at line 22 of file test-get-transients.cpp.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 40 of file test-get-transients.cpp.

{
  Display                    *dpy;
  Window                     xid = 0;
  X11WindowReadTransients    *window = NULL;
  X11WindowReadTransients    *transient = NULL;
  X11WindowReadTransients    *hasClientLeader = NULL;
  std::vector<unsigned int>  expectedTransients;

  if ((argc == 2 && std::string (argv[1]) == "--help") || argc > 3)
  {
    usage ();
    return 1;
  }

  dpy = XOpenDisplay (NULL);

  if (!dpy)
  {
    std::cerr << "Failed to open display ... setting test to passed" << std::endl;
    return 0;
  }

  if (argc > 1)
    std::stringstream (argv[1]) >> std::hex >> xid;

  window = new X11WindowReadTransients (dpy, xid);

  if (!xid)
  {
    transient = new X11WindowReadTransients (dpy, 0);
    hasClientLeader = new X11WindowReadTransients (dpy, 0);

    transient->makeTransientFor (window);
    window->setClientLeader (window);
    hasClientLeader->setClientLeader (window);
  }

  /* This assumes that compiz/X is going to process
   * our requests in 3 seconds. That's plenty of time */

  sleep (3);
  window->printTransients ();

  if (transient && hasClientLeader)
  {
    expectedTransients.push_back (transient->id ());
    expectedTransients.push_back (hasClientLeader->id ());

    if (expectedTransients != window->transients ())
    {
      delete transient;
      delete hasClientLeader;
      delete window;
      XCloseDisplay (dpy);

      std::cout << "FAIL: returned transients did not match expected transients" << std::endl;
      return 1;
    }
    else
      std::cout << "PASS: returned transients did match expected transients" << std::endl;
  }

  if (transient)
    delete transient;

  delete window;

  XCloseDisplay (dpy);

  return 0;
}

Here is the call graph for this function:

void usage ( )

Definition at line 35 of file test-get-transients.cpp.

{
  std::cout << "test-get-transients [WINDOW]" << std::endl;
}

Here is the caller graph for this function: