Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle running tests on machine with no input context. #19

Open
GoogleCodeExporter opened this issue Mar 14, 2015 · 0 comments
Open

Handle running tests on machine with no input context. #19

GoogleCodeExporter opened this issue Mar 14, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

We've written a couple of WindowLicker  unit tests which ran fine from command 
line locally. However, when we committed them into source repository the Cruise 
Control wasn't able to run them and was throwing an error:


java.lang.NullPointerException 
at 
com.objogate.wl.keyboard.KeyboardLayout.defaultKeyboardLayoutName(KeyboardLayout
.java:75) 
at 
com.objogate.wl.keyboard.KeyboardLayout.getDefaultKeyboardLayout(KeyboardLayout.
java:71) 
at com.objogate.wl.robot.RoboticAutomaton.<init>(RoboticAutomaton.java:27) 
at 
com.objogate.wl.swing.gesture.GesturePerformer.<init>(GesturePerformer.java:13) 
... our code

By looking at the source code I found that the place it fails tries to obtain 
the current country of the current InputContext. I suspect that because Cruise 
Control runs as a service it has limited ability to obtain Java InputContext 
due to security or some other reasons.
So I added a few null checks to make sure it doesn't fail:

I suspect it has to do with the fact that Cruise Control runs as a service and 
thus has limited ability to obtain Java InputContext due to security or some 
other reasons.

src\core\main\com\objogate\wl\keyboard\Keyboard.java

private static String defaultKeyboardLayoutName() {
        String country="US";
        InputContext context = InputContext.getInstance();
        if(context!=null) {
            java.util.Locale locale=context.getLocale();
            if(locale!=null)
                country=locale.getCountry();
        }
        return Platform.is(Platform.Mac) ? "Mac-" + country : country;
    }

I think it's pretty safe fix. Could somebody add this fix to main repository so 
it's not lost. I am sure others will run into it sooner or later.

Thanks.

Original issue reported on code.google.com by [email protected] on 27 Aug 2012 at 2:02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant