Exemplo n.º 1
0
    void shouldBeAbleToRegisterAnInvalidRequestHandler()
    {
      Dispatcher dispatcher;
      dispatcher.setInvalidRequestHandler(new ReturnNameHandler("invalid"));

      QCOMPARE(dispatcher.handleRequest("class1/click/button1"), QString("invalid"));
      QCOMPARE(dispatcher.handleRequest("class2/click/button1"), QString("invalid"));
      QCOMPARE(dispatcher.handleRequest("invalid"), QString("invalid"));
    }
Exemplo n.º 2
0
    void shouldBeAbleToGetErrorMessageWithRequest()
    {
      Dispatcher dispatcher;
      dispatcher.registerClass("class1", new ErrorMessageHandler());

      QCOMPARE(dispatcher.handleRequest("class1/click/button1"), QString("Unable to find top level object \"button1\""));
    }
Exemplo n.º 3
0
    void shouldBeAbleToUnregisterAClass()
    {
      Dispatcher dispatcher;
      dispatcher.registerClass("class1", new ReturnNameHandler("class1"));
      dispatcher.unRegisterClass("class1");      

      QCOMPARE(dispatcher.handleRequest("class1/click/button1"), QString(""));
    }
Exemplo n.º 4
0
    void shouldBeAbleToUnregisterAnObject()
    {
      Dispatcher dispatcher;
      dispatcher.registerClass("class1", new ReturnObjectNameHandler());
      dispatcher.registerObject("button1", new ObjectWithName("button1"));
      dispatcher.unRegisterObject("button1");

      QCOMPARE(dispatcher.handleRequest("class1/click/button1"), QString("null"));
    }