1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-07-12 21:10:02 -04:00
commit 794b5a232f
3099 changed files with 238212 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import org.junit.*;
public class ClipboardAdp__tst {
@Test public void Basic() {
ClipboardAdp_.SetText("test");
Tfds.Eq(true, ClipboardAdp_.IsText());
Tfds.Eq("test", ClipboardAdp_.GetText());
}
}

View File

@@ -0,0 +1,53 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import org.junit.*;
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);
}

View File

@@ -0,0 +1,31 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import org.junit.*;
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,87 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import org.junit.*;
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_.Xto_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;
}

View File

@@ -0,0 +1,35 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import org.junit.*;
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;
}

View File

@@ -0,0 +1,49 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfxAdpMok implements GfxAdp {
public GfxItmList SubItms() {return subItms;} GfxItmList subItms = new GfxItmList();
public void DrawStringXtn(String s, FontAdp font, SolidBrushAdp brush, float x, float y, float width, float height, GfxStringData sd) {
float[] sizeAry = MeasureStringXtn(s, font, null);
SizeAdp size = SizeAdp_.new_((int)sizeAry[0], (int)sizeAry[1]);
GfxStringItm str = GfxStringItm.new_(PointAdp_.new_((int)x, (int)y), size, s, font, brush);
subItms.Add(str);
}
public void DrawRect(PenAdp pen, PointAdp location, SizeAdp size) {this.DrawRect(pen, location.X(), location.Y(), size.Width(), size.Height());}
public void DrawRect(PenAdp pen, RectAdp rect) {this.DrawRect(pen, rect.X(), rect.Y(), rect.Width(), rect.Height());}
public void DrawRect(PenAdp pen, int x, int y, int width, int height) {
GfxRectItm rect = GfxRectItm.new_(PointAdp_.new_(x, y), SizeAdp_.new_(width, height), pen.Width(), pen.Color());
subItms.Add(rect);
}
public void DrawLine(PenAdp pen, PointAdp src, PointAdp trg) {
GfxLineItm line = GfxLineItm.new_(src, trg, pen.Width(), pen.Color());
subItms.Add(line);
}
public void DrawImage(ImageAdp image, PointAdp location) {
// gfx.DrawImage(image, width, height);
}
public void DrawImage(ImageAdp img, int trg_x, int trg_y, int trg_w, int trg_h, int src_x, int src_y, int src_w, int src_h) {
// gfx.DrawImage(image, dst, src, GraphicsUnit.Pixel);
}
public void FillRect(SolidBrushAdp brush, int x, int y, int width, int height) {
// gfx.FillRect(brush, x, y, width, height);
}
public float[] MeasureStringXtn(String s, FontAdp font, GfxStringData str) {return new float[] {13 * String_.Len(s), 17};}
public void Rls() {}
public static GfxAdpMok new_() {return new GfxAdpMok();} GfxAdpMok() {}
}

View File

@@ -0,0 +1,19 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public interface GfxItm {}

View File

@@ -0,0 +1,30 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfxItmList extends List_adp_base {
@gplx.New public GfxItm Get_at(int i) {return (GfxItm)Get_at_base(i);}
public void Add(GfxItm gfxItm) {Add_base(gfxItm);}
}
class GfxItmListFxt {
public void tst_SubItm_count(GfxAdpMok gfx, int expd) {Tfds.Eq(expd, gfx.SubItms().Count());}
public void tst_SubItm(GfxAdpMok gfx, int i, GfxItm expd) {
GfxItm actl = gfx.SubItms().Get_at(i);
Tfds.Eq(expd, actl);
}
public static GfxItmListFxt new_() {return new GfxItmListFxt();} GfxItmListFxt() {}
}

View File

@@ -0,0 +1,34 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import gplx.core.strings.*;
public abstract class GfxItm_base implements GfxItm {
public PointAdp Pos() {return pos;} PointAdp pos = PointAdp_.Zero;
public SizeAdp Size() {return size;} SizeAdp size = SizeAdp_.Zero;
@Override public String toString() {return String_bldr_.new_().Add_kv_obj("pos", pos).Add_kv_obj("size", size).XtoStr();}
@Override public int hashCode() {return this.toString().hashCode();}
@Override public boolean equals(Object obj) {
GfxItm_base comp = GfxItm_base.as_(obj); if (comp == null) return false;
return Object_.Eq(pos, comp.pos) && Object_.Eq(size, comp.size);
}
@gplx.Virtual public void ctor_GfxItmBase(PointAdp posVal, SizeAdp sizeVal) {
pos = posVal; size = sizeVal;
}
public static GfxItm_base as_(Object obj) {return obj instanceof GfxItm_base ? (GfxItm_base)obj : null;}
public static GfxItm_base cast_(Object obj) {try {return (GfxItm_base)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, GfxItm_base.class, obj);}}
}

View File

@@ -0,0 +1,40 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import gplx.core.strings.*;
public class GfxLineItm implements GfxItm {
public PointAdp Src() {return src;} PointAdp src = PointAdp_.Zero;
public PointAdp Trg() {return trg;} PointAdp trg = PointAdp_.Zero;
public float Width() {return width;} float width;
public ColorAdp Color() {return color;} ColorAdp color;
@Override public String toString() {return String_bldr_.new_().Add_kv_obj("src", src).Add_kv_obj("trg", trg).Add_kv_obj("width", width).Add_kv_obj("color", color.XtoHexStr()).XtoStr();}
@Override public int hashCode() {return this.toString().hashCode();}
@Override public boolean equals(Object obj) {
GfxLineItm comp = GfxLineItm.as_(obj); if (comp == null) return false;
return src.Eq(comp.src) && trg.Eq(comp.trg) && width == comp.width && color.Eq(comp.color);
}
public static GfxLineItm new_(PointAdp src, PointAdp trg, float width, ColorAdp color) {
GfxLineItm rv = new GfxLineItm();
rv.src = src; rv.trg = trg;
rv.width = width; rv.color = color;
return rv;
} GfxLineItm() {}
public static GfxLineItm as_(Object obj) {return obj instanceof GfxLineItm ? (GfxLineItm)obj : null;}
public static GfxLineItm cast_(Object obj) {try {return (GfxLineItm)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, GfxLineItm.class, obj);}}
}

View File

@@ -0,0 +1,37 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import gplx.core.strings.*;
public class GfxRectItm extends GfxItm_base {
public float Width() {return width;} float width;
public ColorAdp Color() {return color;} ColorAdp color;
@Override public String toString() {return String_.Concat(super.toString(), String_bldr_.new_().Add_kv_obj("width", width).Add_kv("color", color.XtoHexStr()).XtoStr());}
@Override public int hashCode() {return this.toString().hashCode();}
@Override public boolean equals(Object obj) {
GfxRectItm comp = GfxRectItm.as_(obj); if (comp == null) return false;
return super.equals(comp) && width == comp.width && color.Eq(comp.color);
}
public static GfxRectItm new_(PointAdp pos, SizeAdp size, float width, ColorAdp color) {
GfxRectItm rv = new GfxRectItm();
rv.ctor_GfxItmBase(pos, size);
rv.width = width; rv.color = color;
return rv;
} GfxRectItm() {}
@gplx.New public static GfxRectItm as_(Object obj) {return obj instanceof GfxRectItm ? (GfxRectItm)obj : null;}
}

View File

@@ -0,0 +1,38 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfxStringItm extends GfxItm_base {
public String Text() {return text;} private String text;
public FontAdp Font() {return font;} FontAdp font;
public SolidBrushAdp Brush() {return brush;} SolidBrushAdp brush;
@Override public int hashCode() {return this.toString().hashCode();}
@Override public boolean equals(Object obj) {
GfxStringItm comp = GfxStringItm.as_(obj); if (comp == null) return false;
return super.equals(obj) && String_.Eq(text, comp.text) && font.Eq(comp.font) && brush.Eq(comp.brush);
}
public static GfxStringItm new_(PointAdp pos, SizeAdp size, String text, FontAdp font, SolidBrushAdp brush) {
GfxStringItm rv = new GfxStringItm();
rv.ctor_GfxItmBase(pos, size);
rv.text = text; rv.font = font; rv.brush = brush;
return rv;
} GfxStringItm() {}
public static GfxStringItm test_(String text, FontAdp font, SolidBrushAdp brush) {
return GfxStringItm.new_(PointAdp_.Null, SizeAdp_.Null, text, font, brush);
}
@gplx.New public static GfxStringItm as_(Object obj) {return obj instanceof GfxStringItm ? (GfxStringItm)obj : null;}
}

View File

@@ -0,0 +1,45 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import org.junit.*;
import gplx.ios.*;
import gplx.security.*;
public class ImageAdp_tst {
@Before public void setup() {
load = Tfds.RscDir.GenSubFil_nest("150_gfui", "imgs", "strawberry_java.bmp");
} ImageAdp img; Io_url load;
@Test public void load_() {
img = ImageAdp_.file_(load);
Tfds.Eq(80, img.Width());
Tfds.Eq(80, img.Height());
Tfds.Eq("80,80", img.Size().toString());
Tfds.Eq(img.Url(), load);
}
@Test public void SaveAsBmp() {
img = ImageAdp_.file_(load);
Io_url save = load.GenNewNameOnly("strawberry_temp");
DateAdp beforeModifiedTime = Io_mgr.I.QueryFil(save).ModifiedTime();
img.SaveAsBmp(save);
DateAdp afterModifiedTime = Io_mgr.I.QueryFil(save).ModifiedTime();
Tfds.Eq_true(CompareAble_.Is_more(afterModifiedTime, beforeModifiedTime));
String loadHash = HashAlgo_.Md5.CalcHash(ConsoleDlg_.Null, Io_mgr.I.OpenStreamRead(load));
String saveHash = HashAlgo_.Md5.CalcHash(ConsoleDlg_.Null, Io_mgr.I.OpenStreamRead(save));
Tfds.Eq(loadHash, saveHash);
}
}

View File

@@ -0,0 +1,63 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import org.junit.*;
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,34 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import org.junit.*;
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,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import org.junit.*;
public class ScreenAdp_tst {
@Test public void parse_() {
ScreenAdp actl = ScreenAdp_.parse_("{screen{0}");
Tfds.Eq(0, actl.Index());
}
@Test public void opposite_() {
ScreenAdp actl = ScreenAdp_.from_point_(PointAdp_.new_(2000, 2000));
Tfds.Eq(0, actl.Index());
}
}

View File

@@ -0,0 +1,131 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import org.junit.*;
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 GfoInvkAble {
@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_.Xto_str(i), Int_.Xto_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._;
// 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 GfoInvkAble_.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;
}