Comments (2)
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.
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)
- getting GwtMockitoTestRunner$FailedCastException in DateBox HOT 1
- ClassCastException with JsArrayInteger HOT 1
- Since Mockito 2.1.0 TextBox.setValue(null) does not work anymore HOT 4
- ToggleButton ClassCastException
- What does it mean "Illegal class modifiers" ? HOT 1
- JaCoCo support not working HOT 7
- Better GWT unit testing http://google.github.io/gwtmockito hyperLink HOT 2
- Provide an example in the samples or documentation for doing code coverage HOT 1
- #68 broke the build HOT 1
- Java 9 support HOT 2
- gwtmockito and GXT HOT 1
- Java 10 upgrade: java.lang.IllegalStateException HOT 3
- javassist 3.22.0-GA breaks gwtmockito ("class is frozen") HOT 3
- Mockito failure with Java11 HOT 1
- gwtmockito v1.1.9 is not available in public repos HOT 3
- IllegalAccessError when using GwtMockitoTestRunner
- Release 1.1.9 is incomplete in maven repository HOT 1
- ClassCastException When Calling MenuItem.setTitle HOT 2
- Junit5 support HOT 1
- Problem with Java 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gwtmockito.