mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Wikibase: Fix script error 'libraryUtil.lua:13 bad argument #1 to message.newRawMessage' on sever dozen military pages
This commit is contained in:
51
150_gfui/src/gplx/gfui/controls/GfuiBorderMgr_tst.java
Normal file
51
150_gfui/src/gplx/gfui/controls/GfuiBorderMgr_tst.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
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.controls; import gplx.*; import gplx.gfui.*;
|
||||
import org.junit.*; import gplx.gfui.draws.*; import gplx.gfui.imgs.*;
|
||||
public class GfuiBorderMgr_tst {
|
||||
@Before public void setup() {
|
||||
borderMgr = GfuiBorderMgr.new_();
|
||||
}
|
||||
@Test public void NullToEdge() { // all null -> one edge
|
||||
tst_Eq(borderMgr, null, null, null, null, null);
|
||||
|
||||
borderMgr.Top_(red);
|
||||
tst_Eq(borderMgr, null, red, null, null, null);
|
||||
}
|
||||
@Test public void EdgeToAll() { // one edge -> all edge
|
||||
borderMgr.Top_(red);
|
||||
tst_Eq(borderMgr, null, red, null, null, null);
|
||||
|
||||
borderMgr.All_(black);
|
||||
tst_Eq(borderMgr, black, null, null, null, null);
|
||||
}
|
||||
@Test public void AllToEdge() { // all edge -> one new; three old
|
||||
borderMgr.All_(red);
|
||||
tst_Eq(borderMgr, red, null, null, null, null);
|
||||
|
||||
borderMgr.Top_(black);
|
||||
tst_Eq(borderMgr, null, black, red, red, red);
|
||||
}
|
||||
void tst_Eq(GfuiBorderMgr borderMgr, PenAdp all, PenAdp top, PenAdp left, PenAdp right, PenAdp bottom) {
|
||||
Tfds.Eq(borderMgr.All(), all);
|
||||
Tfds.Eq(borderMgr.Top(), top);
|
||||
Tfds.Eq(borderMgr.Left(), left);
|
||||
Tfds.Eq(borderMgr.Right(), right);
|
||||
Tfds.Eq(borderMgr.Bot(), bottom);
|
||||
}
|
||||
GfuiBorderMgr borderMgr;
|
||||
PenAdp black = PenAdp_.black_(), red = PenAdp_.new_(ColorAdp_.Red, 1);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
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.controls.customs; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import org.junit.*; import gplx.gfui.ipts.*; import gplx.gfui.controls.windows.*; import gplx.gfui.controls.standards.*; import gplx.gfui.controls.customs.*;
|
||||
public class GfuiMoveElemBtn_tst {
|
||||
@Before public void setup() {
|
||||
form = GfuiWin_.app_("form"); form.Size_(100, 100);
|
||||
moveBtn = GfuiBtn_.new_("moveBtn");
|
||||
GfuiMoveElemBnd bnd = GfuiMoveElemBnd.new_(); bnd.TargetElem_set(form);
|
||||
moveBtn.IptBnds().Add(bnd);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
Tfds.Eq(form.X(), 0);
|
||||
IptEventMgr.ExecKeyDown(moveBtn, IptEvtDataKey.test_(MoveRightArg()));
|
||||
Tfds.Eq(form.X(), 10);
|
||||
}
|
||||
|
||||
IptKey MoveRightArg() {return IptKey_.Ctrl.Add(IptKey_.Right);}
|
||||
GfuiWin form; GfuiBtn moveBtn;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
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.controls.standards; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import org.junit.*;
|
||||
public class Gfui_tab_itm_data_tst {
|
||||
@Before public void init() {} private Gfui_tab_itm_data_fxt fxt = new Gfui_tab_itm_data_fxt();
|
||||
@Test public void Get_idx_after_closing() {
|
||||
fxt.Test_Get_idx_after_closing(0, 1, -1);
|
||||
fxt.Test_Get_idx_after_closing(4, 5, 3);
|
||||
fxt.Test_Get_idx_after_closing(3, 5, 4);
|
||||
}
|
||||
}
|
||||
class Gfui_tab_itm_data_fxt {
|
||||
public void Test_Get_idx_after_closing(int cur, int len, int expd) {
|
||||
Tfds.Eq(expd, Gfui_tab_itm_data.Get_idx_after_closing(cur, len));
|
||||
}
|
||||
}
|
||||
129
150_gfui/src/gplx/gfui/controls/tabs/TabBox_tst.java
Normal file
129
150_gfui/src/gplx/gfui/controls/tabs/TabBox_tst.java
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
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.controls.tabs; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import org.junit.*; import gplx.gfui.controls.tabs.*; import gplx.gfui.controls.elems.*; import gplx.gfui.controls.standards.*;
|
||||
public class TabBox_tst {
|
||||
// @Before public void setup() {
|
||||
// fx = TabBoxFxt.new_();
|
||||
// } TabBoxFxt fx;
|
||||
@Test public void Add() {
|
||||
// fx.Make(1).tst_Selected("0").FetchBtnAt(0).tst_X(0);
|
||||
// fx.Make(3).tst_Selected("2").FetchBtnAt(2).tst_X(160);
|
||||
}
|
||||
// @Test public void Del_at() {
|
||||
// fx.Make(2).Del_at(1).tst_Btns("0");
|
||||
// fx.Make(2).Del_at(0).tst_Btns("1");
|
||||
// fx.Make(3).Del_at(0).tst_Btns("1", "2");
|
||||
// fx.Make(3).Del_at(1).tst_Btns("0", "2");
|
||||
// fx.Make(3).Del_at(2).tst_Btns("0", "1");
|
||||
|
||||
// fx.Make(3).Select(1).Del_at(1).tst_Selected("2"); // 1 deleted; 2 shifted down into slot
|
||||
// fx.Make(3).Select(1).Del_at(0).tst_Selected("1"); // 0 deleted; 1 still remains active (but will have idx of 0
|
||||
// fx.Make(3).Select(2).Del_at(2).tst_Selected("1"); // 2 deleted; 1 selected
|
||||
// }
|
||||
// @Test public void Selected_byAdd() {
|
||||
// fx.Make(2).Select(0).tst_Selected("0").Select(1).tst_Selected("1");
|
||||
// }
|
||||
// @Test public void Selected_byBtn() {
|
||||
// fx.Make(2).tst_Selected("1");
|
||||
//
|
||||
// GfuiBtn btn = fx.TabBox().SubBtnArea().Get_at(0);
|
||||
// btn.Click();
|
||||
// fx.tst_Selected("0");
|
||||
// }
|
||||
// @Test public void ReorderTab() {
|
||||
// fx.Make(3).Reorder(0, -1).tst_Raised(false);
|
||||
// fx.Make(3).Reorder(2, 1).tst_Raised(false);
|
||||
// fx.Make(3).Reorder(0, 1).tst_Btns("1", "0", "2").tst_Raised(true).tst_FocusOrder();
|
||||
// fx.Make(3).Reorder(0, 2).tst_Btns("1", "2", "0").tst_Raised(true).tst_FocusOrder();
|
||||
// fx.Make(3).Reorder(2, -1).tst_Btns("0", "2", "1").tst_Raised(true).tst_FocusOrder();
|
||||
// fx.Make(3).Reorder(0, 1).Reorder(1, 2).tst_Btns("0", "2", "1").tst_Raised(true);//.tst_FocusOrder(); // FIXME: broken after FocusOrder set for entire form (instead of per container)
|
||||
// }
|
||||
}
|
||||
class GfuiElemFxt {
|
||||
public GfuiElem UnderElem() {return underElem;} GfuiElem underElem;
|
||||
@gplx.Internal protected GfuiElemFxt tst_X(int expd) {Tfds.Eq(expd, underElem.X()); return this;}
|
||||
public static GfuiElemFxt new_(GfuiElem elem) {
|
||||
GfuiElemFxt rv = new GfuiElemFxt();
|
||||
rv.underElem = elem;
|
||||
return rv;
|
||||
} GfuiElemFxt() {}
|
||||
}
|
||||
class TabBoxFxt implements Gfo_invk {
|
||||
@gplx.Internal protected TabBox TabBox() {return tabBox;}
|
||||
@gplx.Internal protected TabBoxFxt Make(int count) {
|
||||
for (int i = 0; i < tabBox.Tabs_Count(); i++)
|
||||
tabBox.Tabs_DelAt(0);
|
||||
for (int i = 0; i < count; i++)
|
||||
tabBox.Tabs_Add(Int_.To_str(i), Int_.To_str(i));
|
||||
return this;
|
||||
}
|
||||
@gplx.Internal protected TabBoxFxt Del_at(int index) {tabBox.Tabs_DelAt(index); return this;}
|
||||
// @gplx.Internal protected TabBoxFxt Select(int index) {tabBox.Tabs_Select(index); return this;}
|
||||
@gplx.Internal protected GfuiElemFxt FetchBtnAt(int index) {
|
||||
GfuiBtn btn = (GfuiBtn)tabBox.BtnBox().SubElems().Get_at(index);
|
||||
GfuiElemFxt fx_elem = GfuiElemFxt.new_(btn);
|
||||
return fx_elem;
|
||||
}
|
||||
// @gplx.Internal protected TabBoxFxt tst_BtnX(int idx, int expdX) {
|
||||
// Tfds.Eq(expdX, tabBox.SubBtnArea().Get_at(idx).X());
|
||||
// return this;
|
||||
// }
|
||||
@gplx.Internal protected TabBoxFxt tst_Selected(String expd) {
|
||||
TabPnlItm curTab = tabBox.Tabs_SelectedItm();
|
||||
GfuiBtn btn = (GfuiBtn)tabBox.BtnBox().SubElems().Get_at(curTab.Idx());
|
||||
Tfds.Eq(expd, btn.Text());
|
||||
return this;
|
||||
}
|
||||
@gplx.Internal protected TabBoxFxt tst_Btns(String... expd) {
|
||||
String[] actl = new String[tabBox.Tabs_Count() ];
|
||||
for (int i = 0; i < tabBox.Tabs_Count() ; i++) {
|
||||
GfuiBtn button = (GfuiBtn)tabBox.BtnBox().SubElems().Get_at(i);
|
||||
actl[i] = button.TextMgr().Val();
|
||||
}
|
||||
Tfds.Eq_ary(expd, actl);
|
||||
return this;
|
||||
}
|
||||
// @gplx.Internal protected TabBoxFxt tst_Raised(boolean expd) {Tfds.Eq(expd, received != null); return this;}
|
||||
// @gplx.Internal protected TabBoxFxt Reorder(int i, int delta) {
|
||||
// tabBox.Width_(240); // needed for lytMgr
|
||||
// TabBnd_reorderTab reorderBnd = TabBnd_reorderTab.Instance;
|
||||
// received = null;
|
||||
// TabPnl pnl = tabBox.Tabs_FetchAt(i);
|
||||
// reorderBnd.MoveTab(pnl.SubTabBtn(), delta);
|
||||
// return this;
|
||||
// }
|
||||
// @gplx.Internal protected TabBoxFxt tst_FocusOrder() {
|
||||
// for (int i = 0; i < tabBox.SubBtnArea().SubZones().Get_at(0).Count(); i++) {
|
||||
// GfuiElem subBtn = (GfuiElem)tabBox.SubBtnArea().SubZones().Get_at(0).Get_at(i);
|
||||
// Tfds.Eq(i, subBtn.UnderElem().Core().Focus_index());
|
||||
// }
|
||||
// return this;
|
||||
// }
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, OrderChangedReceived_cmd)) OrderChangedReceived(m);
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} public static final String OrderChangedReceived_cmd = "OrderChangedReceived";
|
||||
TabBox tabBox;
|
||||
public static TabBoxFxt new_() {
|
||||
TabBoxFxt rv = new TabBoxFxt();
|
||||
rv.tabBox = TabBox_.new_();
|
||||
return rv;
|
||||
} TabBoxFxt() {}
|
||||
void OrderChangedReceived(GfoMsg msg) {
|
||||
} //int[] received = null;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
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.controls.windows; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import org.junit.*; import gplx.gfui.controls.elems.*;
|
||||
public class GfuiFocusOrderer_tst {
|
||||
@Before public void setup() {
|
||||
owner = GfuiElem_.new_();
|
||||
list = List_adp_.New(); // list of all controls
|
||||
}
|
||||
@Test public void Horizontal() {
|
||||
ini_Subs(owner, list, xy_(40, 0), xy_(20, 0), xy_(0, 0));
|
||||
tst_FocusIndxs(owner, list, 0, 1, 2);
|
||||
|
||||
GfuiFocusOrderer.OrderByX(owner);
|
||||
tst_FocusIndxs(owner, list, 2, 1, 0);
|
||||
}
|
||||
@Test public void Vertical() {
|
||||
ini_Subs(owner, list, xy_(0, 40), xy_(0, 20), xy_(0, 0));
|
||||
tst_FocusIndxs(owner, list, 0, 1, 2);
|
||||
|
||||
GfuiFocusOrderer.OrderByY(owner);
|
||||
tst_FocusIndxs(owner, list, 2, 1, 0);
|
||||
}
|
||||
@Test public void Grid() {
|
||||
ini_Subs(owner, list, xy_(20, 20), xy_(0, 20), xy_(20, 0), xy_(0, 0));
|
||||
tst_FocusIndxs(owner, list, 0, 1, 2, 3);
|
||||
|
||||
GfuiFocusOrderer.OrderByX(owner);
|
||||
tst_FocusIndxs(owner, list, 3, 2, 1, 0);
|
||||
}
|
||||
@Test public void Deep() {
|
||||
ini_Subs(owner, list, xy_(20, 0), xy_(0, 0));
|
||||
GfuiElem sub0 = sub_(owner, 0), sub1 = sub_(owner, 1);
|
||||
ini_Subs(sub0, list, xy_(20, 0), xy_(0, 0));
|
||||
ini_Subs(sub1, list, xy_(20, 0), xy_(0, 0));
|
||||
tst_FocusIndxs(owner, list, 0, 1, 0, 1, 0, 1); // 2 owner controls (0, 1); each has two subs (0, 1)
|
||||
|
||||
GfuiFocusOrderer.OrderByX(owner);
|
||||
tst_FocusIndxs(owner, list, 3, 0, 5, 4, 2, 1);
|
||||
}
|
||||
@Test public void Manusl() {
|
||||
ini_Subs(owner, list, xy_(0, 0), xy_(20, 0));
|
||||
tst_FocusIndxs(owner, list, 0, 1);
|
||||
|
||||
GfuiElem sub1 = owner.SubElems().Get_at(0);
|
||||
GfuiElem sub2 = owner.SubElems().Get_at(1);
|
||||
sub1.Focus_idx_(1);
|
||||
sub2.Focus_idx_(0);
|
||||
|
||||
GfuiFocusOrderer.OrderByX(owner);
|
||||
tst_FocusIndxs(owner, list, 1, 0);
|
||||
}
|
||||
PointAdp xy_(int x, int y) {return PointAdp_.new_(x, y);}
|
||||
GfuiElem sub_(GfuiElem owner, int i) {return owner.SubElems().Get_at(i);}
|
||||
void ini_Subs(GfuiElem owner, List_adp list, PointAdp... points) {
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
GfuiElem sub = GfuiElem_.sub_(Int_.To_str(i), owner);
|
||||
sub.Pos_(points[i]);
|
||||
sub.UnderElem().Core().Focus_index_set(i);
|
||||
list.Add(sub);
|
||||
}
|
||||
}
|
||||
void tst_FocusIndxs(GfuiElem owner, List_adp list, int... expd) {
|
||||
int[] actl = new int[list.Count()];
|
||||
for (int i = 0; i < actl.length; i++) {
|
||||
GfuiElem sub = (GfuiElem)list.Get_at(i);
|
||||
actl[i] = sub.UnderElem().Core().Focus_index();
|
||||
}
|
||||
Tfds.Eq_ary(expd, actl);
|
||||
}
|
||||
GfuiElem owner; List_adp list;
|
||||
}
|
||||
Reference in New Issue
Block a user