You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gnosygnu_xowa/150_gfui/tst/gplx/gfui/ImageAdp_tst.java

47 lines
1.8 KiB

9 years ago
/*
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.*;
9 years ago
import gplx.core.consoles.*;
9 years ago
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");
9 years ago
DateAdp beforeModifiedTime = Io_mgr.Instance.QueryFil(save).ModifiedTime();
9 years ago
img.SaveAsBmp(save);
9 years ago
DateAdp afterModifiedTime = Io_mgr.Instance.QueryFil(save).ModifiedTime();
9 years ago
Tfds.Eq_true(CompareAble_.Is_more(afterModifiedTime, beforeModifiedTime));
9 years ago
String loadHash = HashAlgo_.Md5.CalcHash(Console_adp_.Noop, Io_mgr.Instance.OpenStreamRead(load));
String saveHash = HashAlgo_.Md5.CalcHash(Console_adp_.Noop, Io_mgr.Instance.OpenStreamRead(save));
9 years ago
Tfds.Eq(loadHash, saveHash);
}
}