JSONObject context = new JSONObject()
.put("language", Locale.US.getLanguage())
.put("country", Locale.US.getCountry().toUpperCase())
.put("context-field", "context-value");
GadgetContext jsonContext = new JsonRpcGadgetContext(context, gadget);
assertEquals(SPEC_URL, jsonContext.getUrl().toString());
assertEquals(SPEC_ID, jsonContext.getModuleId());
assertEquals(Locale.US.getLanguage(),
jsonContext.getLocale().getLanguage());
assertEquals(Locale.US.getCountry(), jsonContext.getLocale().getCountry());
for (String key : PREF_KEYS) {
String value = jsonContext.getUserPrefs().getPref(key);
assertEquals(prefs.get(key), value);
}
assertEquals("gadget-value", jsonContext.getParameter("gadget-field"));
assertEquals("context-value", jsonContext.getParameter("context-field"));
}