1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

App: Release v4.5.15.1709

This commit is contained in:
gnosygnu
2017-09-17 22:39:30 -04:00
parent 4ca98f7333
commit ea3f0ffbcc
896 changed files with 69373 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.htmls.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
import org.junit.*; import gplx.xowa.xtns.wbases.*;
import gplx.xowa.guis.views.*;
public class Xoh_js_cbk_tst {
@Before public void init() {fxt.Clear();} private Xoh_js_cbk_fxt fxt = new Xoh_js_cbk_fxt();
@Test public void Get_title() {
fxt.Fxt().Init_page_create("exists");
fxt.Test_get_title("exists", "1" , "0" , Int_.To_str(Int_.Min_value), "Exists", "false", "0001-01-01 00:00:00", "0");
fxt.Test_get_title("absent", "0", "-1", Int_.To_str(Int_.Min_value), null , "false", "0001-01-01 00:00:00", "0");
}
}
class Xoh_js_cbk_fxt {
public void Clear() {
fxt = new Xop_fxt();
Xoa_app_fxt.Init_gui(fxt.App(), fxt.Wiki());
} private Xop_fxt fxt;
public Xop_fxt Fxt() {return fxt;}
public void Test_get_title(String ttl, Object... expd) {
Xoae_app app = fxt.App();
Xowe_wiki wiki = fxt.Wiki();
Xoae_page page = Xoae_page.New_test(wiki, Xoa_ttl.Parse(wiki, Bry_.new_a7("mock_page")));
Xog_tab_itm tab = app.Gui_mgr().Browser_win().Active_tab();
tab.Page_(page);
Xoh_js_cbk exec = tab.Html_itm().Js_cbk();
GfoMsg msg = GfoMsg_.new_cast_(Xoh_js_cbk.Invk_get_titles_meta).Add("ttl", ttl);
String[][] actl = (String[][])Gfo_invk_.Invk_by_msg(exec, Xoh_js_cbk.Invk_get_titles_meta, msg);
Tfds.Eq_ary_str(expd, actl[0]);
}
}

View File

@@ -0,0 +1,61 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.htmls.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
import org.junit.*; import gplx.langs.jsons.*; import gplx.xowa.xtns.wbases.*;
public class Xoh_js_cbk_wdata_labels_tst {
@Before public void init() {fxt.Init();} private final Wdata_wiki_mgr_fxt fxt = new Wdata_wiki_mgr_fxt();
@Test public void Basic() {
fxt.Init__docs__add(fxt.Wdoc_bldr("q1").Add_label("en", "en_q1").Xto_wdoc());
fxt.Init__docs__add(fxt.Wdoc_bldr("q2").Add_label("en", "en_q2").Xto_wdoc());
fxt.Init__docs__add(fxt.Wdoc_bldr("Property:P1").Add_label("en", "en_property_p1").Xto_wdoc());
Tst_wikidata_label_get(String_.Ary("en", "q1", "q2", "Property:P1"), String_.Ary("en_q1", "en_q2", "en_property_p1"));
}
@Test public void Outliers() {
fxt.Init__docs__add(fxt.Wdoc_bldr("q1").Add_label("en", "en_q1").Add_label("de", "de_q1").Xto_wdoc());
Tst_wikidata_label_get(String_.Ary("fr", "q1"), String_.Ary((String)null));
Tst_wikidata_label_get(String_.Ary("de", "q1"), String_.Ary("de_q1"));
Tst_wikidata_label_get(String_.Ary("xowa_title", "q1"), String_.Ary("q1"));
Tst_wikidata_label_get(String_.Ary("xowa_ui_lang", "q1"), String_.Ary("en_q1"));
Tst_wikidata_label_get(String_.Ary("fr;de", "q1"), String_.Ary("de_q1"));
}
@Test public void Escaped() { // PURPOSE: \t should be escaped; EX:wd.q:2; DATE:2014-04-23
Wdata_doc d = doc_("q1", String_.Concat_lines_nl
( "{ 'entity':['item',1]"
, ", 'label':"
, " { 'en':'\\ta'" // NOTE: json literally has "\t", not (char)8
, " }"
, "}"
));
fxt.Init__docs__add(d);
Tst_wikidata_label_get(String_.Ary("en", "q1"), String_.Ary("\ta"));
}
private Wdata_doc doc_(String qid, String src) {
Json_doc jdoc = fxt.Make_json(src);
Xoae_app app = Xoa_app_fxt.Make__app__edit();
Wdata_doc rv = new Wdata_doc(Bry_.new_a7(qid), app.Wiki_mgr().Wdata_mgr(), jdoc);
return rv;
}
private void Tst_wikidata_label_get(String[] args, String[] expd) {
Xoa_app_fxt.Init_gui(fxt.App(), fxt.Wiki());
Xoh_js_cbk exec = fxt.App().Gui_mgr().Browser_win().Active_html_itm().Js_cbk();
GfoMsg msg = GfoMsg_.new_cast_(Xoh_js_cbk.Invk_wikidata_get_label);
int args_len = args.length;
for (int i = 0; i < args_len; i++)
msg.Add("v", args[i]);
String[] actl = (String[])Gfo_invk_.Invk_by_msg(exec, Xoh_js_cbk.Invk_wikidata_get_label, msg);
Tfds.Eq_ary_str(expd, actl);
}
}

View File

@@ -0,0 +1,40 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.htmls.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
import org.junit.*;
public class Xoh_js_cleaner_tst {
@Before public void init() {fxt.Init();} private Xoh_js_cleaner_fxt fxt = new Xoh_js_cleaner_fxt();
@Test public void Basic() {fxt.Test_clean("<i>a</i>", "<i>a</i>");}
@Test public void Js_nde() {fxt.Test_clean("a<script>b</script>c", "a&lt;script>b</script>c");}
@Test public void Js_atr() {fxt.Test_clean("a<span onmouseover = 'fail'>b</span>c", "a<span onMouseOver&#61; 'fail'>b</span>c");}
@Test public void Js_atr_noop() {fxt.Test_clean("a onmouseover b", "a onmouseover b");}
@Test public void Js_atr_noop_regionSelect() {fxt.Test_clean("regionSelect=2", "regionSelect=2");}
}
class Xoh_js_cleaner_fxt {
public void Init() {
if (mgr == null) {
app = Xoa_app_fxt.Make__app__edit();
wiki = Xoa_app_fxt.Make__wiki__edit(app);
mgr = wiki.Html_mgr().Js_cleaner();
}
} private Xoae_app app; Xowe_wiki wiki; Xoh_js_cleaner mgr;
public void Test_clean(String raw_str, String expd) {
byte[] raw = Bry_.new_a7(raw_str);
byte[] actl = mgr.Clean(wiki, raw, 0, raw.length);
if (actl == null) actl = raw;
Tfds.Eq(expd, String_.new_a7(actl));
}
}