mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Command-line: Fix curid argument not working 2
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
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.addons.bldrs.files.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
|
||||
import org.junit.*; import gplx.core.ios.*; import gplx.xowa.files.*;
|
||||
public class Xobldr__image__create_tst {
|
||||
private Xobldr__image__create_fxt fxt = new Xobldr__image__create_fxt();
|
||||
@Test public void Basic() {fxt.Init_("A.png" , Xof_media_type.Name_bitmap , Xof_ext_.Bry_png, 220, 110) .Test(Xof_ext_.Id_png);} // A.png -> png
|
||||
@Test public void Ogg_VIDEO() {fxt.Init_("A.ogg" , Xof_media_type.Name_video , Xof_ext_.Bry_ogg, 220, 110) .Test(Xof_ext_.Id_ogv);} // A.ogg and VIDEO -> ogv
|
||||
@Test public void Ogg_VIDEO_null_size() {fxt.Init_("A.ogg" , Xof_media_type.Name_video , Xof_ext_.Bry_ogg, 0, 0) .Test(Xof_ext_.Id_ogg);} // A.ogg but 0,0 -> ogg (not ogv)
|
||||
@Test public void Png_is_jpg() {fxt.Init_("A.png" , Xof_media_type.Name_bitmap , Xof_ext_.Bry_jpg, 220, 110) .Test(Xof_ext_.Id_jpg);} // A.png and jpg -> jpg
|
||||
@Test public void Jpeg_is_jpeg() {fxt.Init_("A.jpeg" , Xof_media_type.Name_bitmap , Xof_ext_.Bry_jpg, 220, 110) .Test(Xof_ext_.Id_jpeg);} // A.jpeg and jpg -> jpeg (unchanged)
|
||||
}
|
||||
class Xobldr__image__create_fxt {
|
||||
private byte[] name, media_type, minor_mime; int w, h;
|
||||
public Xobldr__image__create_fxt Init_png() {Name_("A.png").Media_type_(Xof_media_type.Name_bitmap).Minor_mime_(Xof_ext_.Bry_png).W_(220).H_(110);
|
||||
return this;
|
||||
}
|
||||
public Xobldr__image__create_fxt Init_(String name, String media_type, byte[] minor_mime, int w, int h) {
|
||||
Name_(name);
|
||||
Media_type_(media_type);
|
||||
Minor_mime_(minor_mime);
|
||||
W_(w);
|
||||
H_(h);
|
||||
return this;
|
||||
}
|
||||
public Xobldr__image__create_fxt Name_(String v) {name = Bry_.new_a7(v); return this;}
|
||||
public Xobldr__image__create_fxt Media_type_(String v) {media_type = Bry_.new_a7(v); return this;}
|
||||
public Xobldr__image__create_fxt Minor_mime_(byte[] v) {minor_mime = v; return this;}
|
||||
public Xobldr__image__create_fxt Minor_mime_(String v) {return Minor_mime_(Bry_.new_a7(v));}
|
||||
public Xobldr__image__create_fxt W_(int v) {w = v; return this;}
|
||||
public Xobldr__image__create_fxt H_(int v) {h = v; return this;}
|
||||
public Xobldr__image__create_fxt Test(int expd) {
|
||||
Tfds.Eq(expd, Xobldr__image__create.Calc_ext_id(Gfo_usr_dlg_.Noop, name, media_type, minor_mime, w, h));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
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.addons.bldrs.files.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
|
||||
import org.junit.*;
|
||||
public class Xobldr__lnki_temp__create__tst {
|
||||
private Xobldr__lnki_temp__create__fxt fxt = new Xobldr__lnki_temp__create__fxt();
|
||||
@Test public void Xto_commons() {
|
||||
fxt.Init__to_commons(true);
|
||||
fxt.Test__to_commons("a", "A");
|
||||
fxt.Test__to_commons("A", null);
|
||||
fxt.Init__to_commons(false);
|
||||
fxt.Test__to_commons("a", null);
|
||||
fxt.Test__to_commons("A", null);
|
||||
}
|
||||
}
|
||||
class Xobldr__lnki_temp__create__fxt {
|
||||
private boolean wiki_ns_file_is_case_match_all;
|
||||
private Xowe_wiki commons_wiki;
|
||||
public Xobldr__lnki_temp__create__fxt Init__to_commons(boolean wiki_ns_file_is_case_match_all) {
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
this.wiki_ns_file_is_case_match_all = wiki_ns_file_is_case_match_all;
|
||||
this.commons_wiki = Xoa_app_fxt.Make__wiki__edit(app); // commons_wiki will default to Xow_ns.Id_file of case_match_1st
|
||||
return this;
|
||||
}
|
||||
public void Test__to_commons(String ttl, String expd) {
|
||||
Tfds.Eq(expd, String_.new_u8(gplx.xowa.addons.bldrs.mass_parses.parses.utls.Xomp_lnki_temp_wkr.To_commons_ttl(wiki_ns_file_is_case_match_all, commons_wiki, Bry_.new_u8(ttl))));
|
||||
}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
/*
|
||||
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.addons.bldrs.files.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
|
||||
import org.junit.*;
|
||||
import gplx.core.gfo_ndes.*;
|
||||
import gplx.core.stores.*; import gplx.xowa.files.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.lnkis.files.*;
|
||||
import gplx.xowa.addons.bldrs.files.dbs.*;
|
||||
public class Xob_xfer_temp_itm_tst {
|
||||
private Xob_xfer_temp_itm_fxt fxt = new Xob_xfer_temp_itm_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Pass() {fxt.Test_pass().Test_itm_chk_fail_id_none();}
|
||||
@Test public void Missing_orig() {fxt.Test_fail(Xob_xfer_temp_itm.Chk_tid_orig_page_id_is_null , Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_page_id, null));}
|
||||
@Test public void File_is_audio() {fxt.Test_fail(Xob_xfer_temp_itm.Chk_tid_orig_media_type_is_audio , Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_media_type, Xof_media_type.Name_audio));}
|
||||
@Test public void File_is_mid() {
|
||||
fxt.Test_fail(Xob_xfer_temp_itm.Chk_tid_orig_media_type_is_audio , Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext, Xof_ext_.Id_mid));
|
||||
}
|
||||
@Test public void Redirect_src_is_empty() { // orig_cmd sets all direct files to have "orig_join" == "lnki_ttl"
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ttl , "A.png")
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.png")
|
||||
);
|
||||
fxt.Test_lnki_redirect_src(""); // confirm redirect_src set to ""
|
||||
}
|
||||
@Test public void Redirect_src_has_val() { // orig_cmd sets all redirect files to have "orig_join" = redirect and "lnki_ttl" as orig; EX: A.png redirects to B.png; orig_join will be B.png (the actual image) and redirect_src will be A.png (the original lnki)
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ttl , "B.png")
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.png")
|
||||
);
|
||||
fxt.Test_lnki_redirect_src("A.png"); // confirm redirect_src set to ""
|
||||
}
|
||||
@Test public void Redirect_should_take_trg_ext() {// if "A.png" redirects to "B.jpg", ext_id should be ".jpg" (the actual file) not ".png (lnki_ext_id)
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ttl , "B.jpg")
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.png")
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_jpg) // .png b/c B.jpg
|
||||
);
|
||||
fxt.Test_lnki_ext_id(Xof_ext_.Id_jpg); // confirm ext changed to .jpg
|
||||
}
|
||||
@Test public void Thumbtime_check() {// PURPOSE: one image actually had a thumbtime defined; EX: General_Dynamics_F-16_Fighting_Falcon; [[File:Crash.arp.600pix.jpg|thumb|thumbtime=2]]
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_jpg)
|
||||
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_time , (double)3)
|
||||
);
|
||||
fxt.Test_lnki_thumbtime(Xof_lnki_time.Null);
|
||||
fxt.Reset().Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_media_type , Xof_media_type.Name_video)
|
||||
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_time , (double)3)
|
||||
);
|
||||
fxt.Test_lnki_thumbtime(3);
|
||||
}
|
||||
@Test public void Page_check() {
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_jpg)
|
||||
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_page , 3)
|
||||
);
|
||||
fxt.Test_lnki_page(Xof_lnki_page.Null);
|
||||
fxt.Reset().Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_pdf)
|
||||
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_page , 3)
|
||||
);
|
||||
fxt.Test_lnki_page(3);
|
||||
fxt.Reset().Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_djvu)
|
||||
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_page , 3)
|
||||
);
|
||||
fxt.Test_lnki_page(3);
|
||||
}
|
||||
@Test public void Media_should_be_ignored() {// ignore [[Media:]] for xfer_thumb (needed for xfer_orig)
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.png")
|
||||
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_src_tid , Xop_file_logger_.Tid__media)
|
||||
);
|
||||
fxt.Test_itm_chk_fail_id(Xob_xfer_temp_itm.Chk_tid_ns_is_media);
|
||||
}
|
||||
@Test public void Orig_width_is_0() {// PURPOSE: ignore files with an orig width of 0; note that ogg files that are sometimes flagged as VIDEO; EX:2009_10_08_Marc_Randazza_interview.ogg; DATE:2014-08-20
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.ogg")
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_media_type , Xof_media_type.Name_video) // VIDEO
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_w , 0) // no width defined in image table
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_h , 0)
|
||||
);
|
||||
fxt.Test_itm_chk_fail_id(Xob_xfer_temp_itm.Chk_tid_orig_w_is_0);
|
||||
}
|
||||
}
|
||||
class Xob_xfer_temp_itm_fxt {
|
||||
private Xob_xfer_temp_itm itm = new Xob_xfer_temp_itm();
|
||||
private Xof_img_size img_size = new Xof_img_size();
|
||||
private DataRdr_mem rdr;
|
||||
private GfoNde nde;
|
||||
public static String[] Flds = new String[]
|
||||
{ Xob_lnki_regy_tbl.Fld_lnki_ext
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_id
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_tier_id
|
||||
, Xob_orig_regy_tbl.Fld_orig_repo
|
||||
, Xob_orig_regy_tbl.Fld_orig_file_ttl
|
||||
, Xob_orig_regy_tbl.Fld_orig_file_ext
|
||||
, Xob_orig_regy_tbl.Fld_lnki_ttl
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_type
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_src_tid
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_w
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_h
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_count
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_page_id
|
||||
, Xob_orig_regy_tbl.Fld_orig_w
|
||||
, Xob_orig_regy_tbl.Fld_orig_h
|
||||
, Xob_orig_regy_tbl.Fld_orig_page_id
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_upright
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_time
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_page
|
||||
, Xob_orig_regy_tbl.Fld_orig_media_type
|
||||
, Xob_orig_regy_tbl.Fld_orig_minor_mime
|
||||
}
|
||||
;
|
||||
public Xob_xfer_temp_itm_fxt Reset() {
|
||||
itm.Clear();
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Init_rdr_image() {
|
||||
GfoFldList flds = GfoFldList_.str_(Flds);
|
||||
nde = GfoNde_.vals_(flds, Object_.Ary
|
||||
( Xof_ext_.Id_png, 1, 1, Xof_repo_tid_.Tid__remote
|
||||
, "A.png", Xof_ext_.Id_png, "A.png", Xop_lnki_type.Id_thumb, Xop_file_logger_.Tid__file
|
||||
, 220, 200, 1, 2, 440, 400, 3
|
||||
, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null, Xof_lnki_page.Null
|
||||
, Xof_media_type.Name_bitmap, "png"
|
||||
));
|
||||
GfoNdeList subs = GfoNdeList_.new_();
|
||||
subs.Add(nde);
|
||||
GfoNde root = GfoNde_.root_(nde);
|
||||
rdr = DataRdr_mem.new_(root, flds, subs);
|
||||
rdr.MoveNextPeer();
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Init_rdr(String key, Object val) {
|
||||
nde.Write(key, val);
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Test_pass() {return Test_bgn();}
|
||||
public Xob_xfer_temp_itm_fxt Test_fail(byte fail_tid, Keyval... kvs) {
|
||||
Test_bgn(kvs);
|
||||
this.Test_itm_chk_fail_id(fail_tid);
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Test_bgn(Keyval... kvs) {
|
||||
Init_rdr_image();
|
||||
int len = kvs.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Keyval kv = kvs[i];
|
||||
Init_rdr(kv.Key(), kv.Val());
|
||||
}
|
||||
this.Exec_load();
|
||||
this.Exec_chk();
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Test_atr(String key, Object val) {
|
||||
Tfds.Eq(rdr.Read(key), val);
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Exec_load() {
|
||||
itm.Load(rdr);
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Exec_chk() {
|
||||
itm.Chk(img_size);
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Test_lnki_ext_id(int expd) {Tfds.Eq(expd, itm.Lnki_ext()); return this;}
|
||||
public Xob_xfer_temp_itm_fxt Test_lnki_thumbtime(double expd) {Tfds.Eq(expd, itm.Lnki_thumbtime()); return this;}
|
||||
public Xob_xfer_temp_itm_fxt Test_lnki_page(int expd) {Tfds.Eq(expd, itm.Lnki_page()); return this;}
|
||||
public Xob_xfer_temp_itm_fxt Test_lnki_redirect_src(String expd) {Tfds.Eq(expd, itm.Redirect_src()); return this;}
|
||||
public Xob_xfer_temp_itm_fxt Test_itm_chk_fail_id_none() {return Test_itm_chk_fail_id(Xob_xfer_temp_itm.Chk_tid_none);}
|
||||
public Xob_xfer_temp_itm_fxt Test_itm_chk_fail_id(byte expd) {
|
||||
Tfds.Eq(expd, itm.Chk_tid());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user