Giter Club home page Giter Club logo

Comments (2)

ekuefler avatar ekuefler commented on May 20, 2024

Could you give some more details about what exactly you're trying to do and how you'd like it to work? It sounds like you want GwtMockito to return a real event bus when you call GWT.create(EventBus.class) instead of a mock. I'm not sure if it makes sense to special-case this in GwtMockito, but it should be possible to make this happen in your own tests by doing something like this:

GwtMockito.useProviderForType(EventBus.class, new FakeProvider() {
  public EventBus getFake(Class<?> type)  {
    return new SimpleEventBus();
  }
});

This will cause GwtMockito to always return a SimpleEventBus from calls to GWT.create, which might do what you want.

The technique I usually use for testing event-based applications is expose event handler methods and call them directly in my tests, rather than firing the event in the test and relying on the event bus to dispatch it. This technique works really well with EventBinder since it requires that you have explicit handler methods.

from gwtmockito.

 avatar commented on May 20, 2024

The use case:
I want to test customized gwt ListBox widget. I have the handler inside the CustomListBox for the ChangeEvent DOM event

new ChangeHandler() {
            @Override
            public void onChange(ChangeEvent event) {
                //... some code here

                //if the new value and previous selection is not equal, fire the change event
                if (fireEvent)
                    ValueChangeEvent.fire(CustomListBox.this, model);
            }
        };

where after some magic i am firing the ValueChangeEvent.

Even if i can emulate DOM event with calling the handler directly from a test , i can't really catch the ValueChangeEvent event from the test to get the changed value.

Also, as i can see in the HandlerManager (which is resposnsible for creating the event bus in the GWT Widget class) is created with a new operator, not with GWT.create(). Will this Fake thing work if the operator is new?

from gwtmockito.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.