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,29 @@
/*
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.gfui.ipts; import gplx.*; import gplx.gfui.*;
import org.junit.*; import gplx.gfui.ipts.*; import gplx.gfui.controls.windows.*;
public class GfuiClickKeyMgr_tst {
@Test public void ExtractKeyFromText() {
tst_ExtractKey("&click", IptKey_.C);
tst_ExtractKey("&", IptKey_.None);
tst_ExtractKey("trailing &", IptKey_.None);
tst_ExtractKey("me & you", IptKey_.None);
}
void tst_ExtractKey(String text, IptKey expd) {
IptKey actl = GfuiWinKeyCmdMgr.ExtractKeyFromText(text);
Tfds.Eq(expd, actl);
}
}

View File

@@ -0,0 +1,60 @@
/*
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.gfui.ipts; import gplx.*; import gplx.gfui.*;
import org.junit.*;
public class IptArgChainMgr_tst {
@Before public void setup() {
fx = new IptArgChainMgr_fx();
} IptArgChainMgr_fx fx;
@Test public void Add() {
fx.run_Add(IptKey_.A, IptKey_.B, IptKey_.C);
fx.tst_(IptKey_.A, 1);
fx.tst_(IptKey_.B, 1);
fx.tst_(IptKey_.C, 2);
fx.tst_(IptKey_.B, 0);
fx.tst_(IptKey_.C, 0);
}
@Test public void Del() {
fx.run_Add(IptKey_.A, IptKey_.B, IptKey_.C);
fx.run_Del(IptKey_.A, IptKey_.B, IptKey_.C);
fx.tst_(IptKey_.A, 0);
fx.tst_(IptKey_.B, 0);
fx.tst_(IptKey_.C, 0);
}
class IptArgChainMgr_fx {
public IptArgChainMgr Under() {return under;} IptArgChainMgr under = new IptArgChainMgr();
public IptArgChainMgr_fx run_Add(IptKey... ary) {under.Add(new IptKeyChain(ary)); return this;}
public IptArgChainMgr_fx run_Del(IptKey... ary) {under.Del(new IptKeyChain(ary)); return this;}
public IptArgChainMgr_fx tst_(IptKey key, int expd) {
String process = under.Process(key);
String activeKey = under.ActiveKey();
String literal = key.Key();
if (expd == 0) {
Tfds.Eq(process, "", "0:{0} should be empty:process", literal);
Tfds.Eq(activeKey, "", "0:{0} should be noop:activeKey", literal);
}
else if (expd == 1) {
Tfds.Eq(process, "", "1:{0} should be empty:process", literal);
Tfds.Eq_true(String_.Has_at_end(activeKey, key.Key() + ","), "1:{0} should set key:activeKey,{1}", literal, activeKey);
}
else if (expd == 2) {
Tfds.Eq_true(String_.EqNot(process, ""), "2:{0} should not be empty;process,{1}", literal, process);
Tfds.Eq(activeKey, "", "2:{0} should be empty:activeKey", literal);
}
return this;
}
}
}

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.gfui.ipts; import gplx.*; import gplx.gfui.*;
import org.junit.*; import gplx.gfui.ipts.*;
public class IptArg_parser_tst {
@Test public void KeyBasic() {
tst_parse_Key_("key.a", IptKey_.A);
tst_parse_Key_("key.d0", IptKey_.D0);
tst_parse_Key_("key.semicolon", IptKey_.Semicolon);
tst_parse_Key_("key.equal", IptKey_.Equal);
tst_parse_Key_("key.pageUp", IptKey_.PageUp);
tst_parse_Key_("key.ctrl", IptKey_.Ctrl);
tst_parse_Key_("key.none", IptKey_.None);
} void tst_parse_Key_(String raw, IptKey expd) {Tfds.Eq(expd.Val(), IptKey_.parse(raw).Val());}
@Test public void KbdCmdModifiers() {
tst_parse_Key_("key.ctrl+key.enter", IptKey_.Ctrl.Add(IptKey_.Enter));
tst_parse_Key_("key.alt+key.escape", IptKey_.Alt.Add(IptKey_.Escape));
tst_parse_Key_("key.shift+key.f1", IptKey_.Shift.Add(IptKey_.F1));
tst_parse_Key_("key.shift+key.ctrl", IptKey_.Ctrl.Add(IptKey_.Shift));
tst_parse_Key_("key.ctrl+key.alt+key.slash", IptKey_.Ctrl.Add(IptKey_.Alt).Add(IptKey_.Slash));
}
@Test public void KeyWhitespace() {
tst_parse_Key_("key.ctrl + key.alt + key.slash", IptKey_.Ctrl.Add(IptKey_.Alt).Add(IptKey_.Slash));
}
@Test public void MouseBtn() {
tst_parse_MouseBtn_("mouse.left", IptMouseBtn_.Left);
tst_parse_MouseBtn_("mouse.right", IptMouseBtn_.Right);
tst_parse_MouseBtn_("mouse.middle", IptMouseBtn_.Middle);
tst_parse_MouseBtn_("mouse.x1", IptMouseBtn_.X1);
tst_parse_MouseBtn_("mouse.x2", IptMouseBtn_.X2);
} void tst_parse_MouseBtn_(String raw, IptMouseBtn expd) {Tfds.Eq(expd, IptMouseBtn_.parse(raw));}
@Test public void MouseWheel() {
tst_parse_MouseWheel_("wheel.up", IptMouseWheel_.Up);
tst_parse_MouseWheel_("wheel.down", IptMouseWheel_.Down);
} void tst_parse_MouseWheel_(String raw, IptMouseWheel expd) {Tfds.Eq(expd, IptMouseWheel_.parse(raw));}
@Test public void Mod() {
tst_parse_("mod.c", IptKey_.Ctrl);
tst_parse_("mod.cs", IptKey_.add_(IptKey_.Ctrl, IptKey_.Shift));
tst_parse_("mod.cas", IptKey_.add_(IptKey_.Ctrl, IptKey_.Alt, IptKey_.Shift));
tst_parse_("mod.c+key.c", IptKey_.add_(IptKey_.Ctrl, IptKey_.C));
}
@Test public void All() {
tst_parse_("key.c", IptKey_.C);
tst_parse_("mouse.left", IptMouseBtn_.Left);
tst_parse_("wheel.up", IptMouseWheel_.Up);
tst_parse_("mod.c", IptKey_.Ctrl);
} void tst_parse_(String raw, IptArg expd) {Tfds.Eq(expd, IptArg_.parse(raw));}
}

View File

@@ -0,0 +1,70 @@
/*
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.gfui.ipts; import gplx.*; import gplx.gfui.*;
import org.junit.*; import gplx.core.strings.*;
public class IptBndMgr_tst {
@Before public void setup() {
fx = new IptBndMgr_fx();
} IptBndMgr_fx fx;
@Test public void Add() {
fx.ini_Clear().run_Add("key.a").tst_Exec_same("key.a").tst_Exec_none("key.b");
fx.ini_Clear().run_Add("key.ctrl+key.a").tst_Exec_same("key.ctrl+key.a").tst_Exec_none("key.ctrl").tst_Exec_none("key.a");
fx.ini_Clear().run_Add("key.a|key.b").tst_Exec_same("key.a").tst_Exec_same("key.b").tst_Exec_none("key.c");
fx.ini_Clear().run_Add("mouse.left").tst_Exec_same("mouse.left");
fx.ini_Clear().run_Add("key.a,key.b")
.tst_Exec_none("key.a").tst_Exec_same("key.b")
.tst_Exec_none("key.a").tst_Exec_none("key.c").tst_Exec_none("key.a").tst_Exec_same("key.b")
.tst_Exec_none("key.a").tst_Exec_none("key.a").tst_Exec_none("key.b");
}
class IptBndMgr_fx {
public IptBndMgr Under() {return under;} IptBndMgr under = IptBndMgr.new_();
public IptBndMgr_fx ini_Clear() {under.Clear(); return this;}
public IptBndMgr_fx run_Add(String raw) {
IptArg[] args = IptArg_.parse_ary_(raw);
List_adp list = List_adp_.New();
for (IptArg arg : args)
list.Add(arg);
IptBnd_mok bnd = new IptBnd_mok(output).Key_(raw).Ipts_(list).EventTypes_(IptEventType_.default_(args));
under.Add(bnd);
return this;
}
public IptBndMgr_fx tst_Exec_none(String key) {return tst_Exec(key, "");}
public IptBndMgr_fx tst_Exec_same(String key) {return tst_Exec(key, key);}
public IptBndMgr_fx tst_Exec(String key, String expd) {
output.Clear();
IptArg[] args = IptArg_.parse_ary_(key);
for (IptArg arg : args) {
IptEventData evData = IptEventData.new_(null, IptArg_.EventType_default(arg), arg, null, null);
under.Process(evData);
}
Tfds.Eq(expd, output.To_str());
return this;
}
String_bldr output = String_bldr_.new_();
public IptBndMgr_fx() {}
}
class IptBnd_mok implements IptBnd {
public String Key() {return key;} public IptBnd_mok Key_(String v) {key = v; return this;} private String key;
public List_adp Ipts() {return args;} public IptBnd_mok Ipts_(List_adp v) {args = v; return this;} List_adp args;
public IptEventType EventTypes() {return eventTypes;} public IptBnd_mok EventTypes_(IptEventType v) {eventTypes = v; return this;} IptEventType eventTypes;
public Object Srl(GfoMsg owner) {return this;}
public void Exec(IptEventData iptData) {
output.Add(iptData.EventArg().Key());
}
public IptBnd_mok(String_bldr v) {output = v;} String_bldr output;
}
}

View File

@@ -0,0 +1,82 @@
/*
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.gfui.ipts; import gplx.*; import gplx.gfui.*;
import org.junit.*;
public class IptCfg_tst {
@Before public void setup() {
IptCfgRegy.Instance.Clear();
box = new IptBndsOwner_mok();
cfg = new IptCfg_mok();
key = IptBndsOwner_mok.Invk_Reg;
} IptBndsOwner_mok box; IptCfg_mok cfg; String key;
@Test public void Basic() {
cfg.run_GetOrDflt(box, key, IptKey_.A);
box.tst_SendKey(IptKey_.A, 1);
}
@Test public void Del() {
cfg.run_GetOrDflt(box, key, IptKey_.A);
box.IptBnds().Cfgs_delAll();
box.tst_SendKey(IptKey_.A, 0);
}
@Test public void Change() {
cfg.run_GetOrDflt(box, key, IptKey_.A);
cfg.run_Set(key, IptKey_.B);
box.tst_SendKey(IptKey_.B, 1);
cfg.run_Set(key, IptKey_.C);
box.tst_SendKey(IptKey_.C, 1);
box.tst_SendKey(IptKey_.B, 0);
}
@Test public void SetBeforeInit() {
cfg.run_Set(key, IptKey_.B);
cfg.run_GetOrDflt(box, key, IptKey_.A);
box.tst_SendKey(IptKey_.B, 1);
box.tst_SendKey(IptKey_.A, 0);
}
@Test public void SetBeforeInit_msg() {
cfg.run_Set_msg(key, 2, IptKey_.B);
cfg.run_GetOrDflt(box, key, IptKey_.A); // iptBnd exists; ignore Key_.A (and also msg=1)
box.tst_SendKey(IptKey_.B, 2);
box.tst_SendKey(IptKey_.A, 0);
}
@Test public void Chained() {
cfg.run_GetOrDflt(box, key, IptKeyChain.parse("key.ctrl+key.a,key.b"));
cfg.run_Set(key, IptKey_.A);
box.tst_SendKey(IptKey_.A, 1);
}
class IptCfg_mok {
public IptCfg Cfg() {return cfg;}
public void run_GetOrDflt(IptBndsOwner box, String key, IptArg... ary) {IptBnd_.msg_(cfg, box, key, make_(key, 1), ary);}
public void run_Set(String key, IptArg... ary) {cfg.Set(key, make_(key, 1), ary);}
public void run_Set_msg(String key, int i, IptArg... ary) {cfg.Set(key, make_(key, i), ary);}
GfoMsg make_(String key, int i) {return GfoMsg_.new_cast_(key).Add("val", i);}
public IptCfg_mok() {cfg = (IptCfg_base)IptCfg_.new_("cfg");} IptCfg_base cfg;
}
class IptBndsOwner_mok implements IptBndsOwner {
public IptBndMgr IptBnds() {return iptBnds;} IptBndMgr iptBnds = IptBndMgr.new_();
public Gfo_evt_mgr Evt_mgr() {if (evt_mgr == null) evt_mgr = new Gfo_evt_mgr(this); return evt_mgr;} Gfo_evt_mgr evt_mgr;
public void tst_SendKey(IptKey key, int expd) {
iptBnds.Process(IptEventData.new_(null, IptEventType_.KeyDown, key, IptEvtDataKey.new_(key), IptEvtDataMouse.Null));
Tfds.Eq(expd, actl);
actl = 0;
} int actl;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_Reg)) {actl = m.ReadIntOr("val", 0);}
else return Gfo_invk_.Rv_unhandled;
return this;
} public static final String Invk_Reg = "Reg";
}
}

View File

@@ -0,0 +1,32 @@
/*
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.gfui.ipts; import gplx.*; import gplx.gfui.*;
import org.junit.*; import gplx.gfui.ipts.*;
public class IptEventType_tst {
@Test public void Has() {
tst_Has(IptEventType_.KeyDown, IptEventType_.KeyDown, true);
tst_Has(IptEventType_.KeyUp, IptEventType_.KeyDown, false);
tst_Has(IptEventType_.None, IptEventType_.KeyDown, false);
tst_Has(IptEventType_.KeyDown, IptEventType_.None, false);
tst_Has(IptEventType_.KeyDown.Add(IptEventType_.KeyUp), IptEventType_.KeyDown, true);
tst_Has(IptEventType_.MouseDown.Add(IptEventType_.MouseUp), IptEventType_.KeyDown, false);
tst_Has(IptEventType_.KeyDown.Add(IptEventType_.KeyUp), IptEventType_.None, false);
} void tst_Has(IptEventType val, IptEventType find, boolean expd) {Tfds.Eq(expd, IptEventType_.Has(val, find));}
@Test public void add_() {
tst_add(IptEventType_.KeyDown, IptEventType_.KeyDown, IptEventType_.KeyDown.Val());
tst_add(IptEventType_.KeyDown, IptEventType_.KeyUp, IptEventType_.KeyDown.Val() + IptEventType_.KeyUp.Val());
} void tst_add(IptEventType lhs, IptEventType rhs, int expd) {Tfds.Eq(expd, IptEventType_.add_(lhs, rhs).Val());}
}

View File

@@ -0,0 +1,57 @@
/*
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.gfui.ipts; import gplx.*; import gplx.gfui.*;
import org.junit.*;
public class IptKeyStrMgr_tst {
@Test public void KeyBasic() {
tst_XtoUiStr(IptKey_.A, "a");
tst_XtoUiStr(IptKey_.Z, "z");
tst_XtoUiStr(IptKey_.Shift.Add(IptKey_.A), "A");
tst_XtoUiStr(IptKey_.Shift.Add(IptKey_.Z), "Z");
tst_XtoUiStrShifted(IptKey_.Equal, "=", "+");
tst_XtoUiStrShifted(IptKey_.D0, "0", ")");
tst_XtoUiStrShifted(IptKey_.D1, "1", "!");
tst_XtoUiStrShifted(IptKey_.D2, "2", "@");
tst_XtoUiStrShifted(IptKey_.D3, "3", "#");
tst_XtoUiStrShifted(IptKey_.D4, "4", "$");
tst_XtoUiStrShifted(IptKey_.D5, "5", "%");
tst_XtoUiStrShifted(IptKey_.D6, "6", "^");
tst_XtoUiStrShifted(IptKey_.D7, "7", "&");
tst_XtoUiStrShifted(IptKey_.D8, "8", "*");
tst_XtoUiStrShifted(IptKey_.D9, "9", "(");
tst_XtoUiStrShifted(IptKey_.Minus, "-", "_");
tst_XtoUiStrShifted(IptKey_.Backslash, "\\", "|");
tst_XtoUiStrShifted(IptKey_.Semicolon, ";", ":");
tst_XtoUiStrShifted(IptKey_.Quote, "'", "\"");
tst_XtoUiStrShifted(IptKey_.Comma, ",", "<");
tst_XtoUiStrShifted(IptKey_.Period, ".", ">");
tst_XtoUiStrShifted(IptKey_.Slash, "?", "/");
tst_XtoUiStrShifted(IptKey_.Tick, "`", "~");
tst_XtoUiStrShifted(IptKey_.OpenBracket, "[", "{");
tst_XtoUiStrShifted(IptKey_.CloseBracket, "]", "}");
}
@Test public void FetchByKeyPress() {
tst_FetchByKeyPress('a', IptKey_.add_(IptKey_.A));
tst_FetchByKeyPress('A', IptKey_.add_(IptKey_.A, IptKey_.Shift));
tst_FetchByKeyPress('1', IptKey_.add_(IptKey_.D1));
tst_FetchByKeyPress('!', IptKey_.add_(IptKey_.D1, IptKey_.Shift));
} void tst_FetchByKeyPress(char c, IptKey expd) {Tfds.Eq(expd.Key(), IptKeyStrMgr.Instance.FetchByKeyPress((int)c).Key());}
void tst_XtoUiStr(IptKey key, String expd) {Tfds.Eq(expd, key.XtoUiStr());}
void tst_XtoUiStrShifted(IptKey key, String expdNormal, String expdShifted) {
Tfds.Eq(expdNormal, key.XtoUiStr());
Tfds.Eq(expdShifted, IptKey_.Shift.Add(key).XtoUiStr());
}
}

View File

@@ -0,0 +1,37 @@
/*
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.gfui.ipts; import gplx.*; import gplx.gfui.*;
import org.junit.*;
public class IptKey__tst {
private final IptKey__fxt fxt = new IptKey__fxt();
@Test public void To_str() {
fxt.Test_to_str(196608, "mod.cs");
}
@Test public void To_str__numeric() {
fxt.Test_to_str(12345, "key.#12345");
}
@Test public void Parse() {
fxt.Test_parse("key.#10", 10);
}
}
class IptKey__fxt {
public void Test_to_str(int keycode, String expd) {
Tfds.Eq(expd, IptKey_.To_str(keycode));
}
public void Test_parse(String raw, int keycode) {
Tfds.Eq(keycode, IptKey_.parse(raw).Val());
}
}