Revision: 2391
http://sourceforge.net/p/swingme/code/2391
Author: yuranet
Date: 2020-06-25 11:31:07 +0000 (Thu, 25 Jun 2020)
Log Message:
-----------
test update
Modified Paths:
--------------
SwingMETest/AndroidManifest.xml
Added Paths:
-----------
SwingMETest/build.gradle
SwingMETest/settings.gradle
SwingMETest/test/
SwingMETest/test/net/
SwingMETest/test/net/yura/
SwingMETest/test/net/yura/mobile/
SwingMETest/test/net/yura/mobile/junit/
SwingMETest/test/net/yura/mobile/junit/JMUnitTest.java
Removed Paths:
-------------
SwingMETest/local.properties
SwingMETest/src/net/yura/mobile/junit/
Modified: SwingMETest/AndroidManifest.xml
===================================================================
--- SwingMETest/AndroidManifest.xml 2020-06-21 14:32:52 UTC (rev 2390)
+++ SwingMETest/AndroidManifest.xml 2020-06-25 11:31:07 UTC (rev 2391)
@@ -4,7 +4,7 @@
android:versionCode="1"
android:versionName="1.0">
- <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14" />
+ <uses-sdk android:targetSdkVersion="14" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
Added: SwingMETest/build.gradle
===================================================================
--- SwingMETest/build.gradle (rev 0)
+++ SwingMETest/build.gradle 2020-06-25 11:31:07 UTC (rev 2391)
@@ -0,0 +1,50 @@
+allprojects {
+ repositories {
+ mavenCentral()
+ jcenter()
+ google()
+ }
+}
+
+buildscript {
+ repositories {
+ mavenCentral()
+ jcenter()
+ google()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:4.0.0'
+ }
+}
+
+apply plugin: 'com.android.application'
+
+dependencies {
+ implementation project(':AndroidME')
+}
+
+android {
+ compileOptions.encoding = 'cp1252'
+ compileSdkVersion 23
+ buildToolsVersion '27.0.3'
+
+ sourceSets {
+ main {
+ manifest.srcFile 'AndroidManifest.xml'
+ java.srcDirs = ['src']
+ resources.srcDirs = ['resources']
+ res.srcDirs = ['res']
+ assets.srcDirs = ['assets']
+ }
+ }
+ // this is to avoid the @TargetApi missing on methods giving errors.
+ lintOptions {
+ abortOnError false
+ }
+ defaultConfig {
+ minSdkVersion 4
+ }
+}
+
+
Deleted: SwingMETest/local.properties
===================================================================
--- SwingMETest/local.properties 2020-06-21 14:32:52 UTC (rev 2390)
+++ SwingMETest/local.properties 2020-06-25 11:31:07 UTC (rev 2391)
@@ -1,10 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must *NOT* be checked in Version Control Systems,
-# as it contains information specific to your local configuration.
-
-# location of the SDK. This is only used by Ant
-# For customization when using a Version Control System, please read the
-# header note.
-sdk.dir=/Users/yuramamyrin/dev/android-sdk-mac_x86
Added: SwingMETest/settings.gradle
===================================================================
--- SwingMETest/settings.gradle (rev 0)
+++ SwingMETest/settings.gradle 2020-06-25 11:31:07 UTC (rev 2391)
@@ -0,0 +1,10 @@
+//include ':..:AndroidME'
+// can not do as above as does not build on Windows http://b.android.com/79505
+// example: https://android.googlesource.com/platform/tools/buildSrc/+/master/base/settings.gradle
+
+include ':AndroidME'
+project(':AndroidME').projectDir = new File(rootDir.getParentFile(), 'AndroidME')
+
+
+// this will only be supported when Android Studio adds support for gradle 3
+//includeBuild '../AndroidME'
Added: SwingMETest/test/net/yura/mobile/junit/JMUnitTest.java
===================================================================
--- SwingMETest/test/net/yura/mobile/junit/JMUnitTest.java (rev 0)
+++ SwingMETest/test/net/yura/mobile/junit/JMUnitTest.java 2020-06-25 11:31:07 UTC (rev 2391)
@@ -0,0 +1,172 @@
+package net.yura.mobile.junit;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Hashtable;
+import java.util.Vector;
+import javax.microedition.io.Connector;
+import javax.microedition.io.StreamConnection;
+import jmunit.framework.cldc11.*;
+import net.yura.mobile.gui.DesktopPane;
+import net.yura.mobile.gui.Midlet;
+import net.yura.mobile.gui.components.Button;
+import net.yura.mobile.gui.components.Frame;
+import net.yura.mobile.gui.components.Panel;
+import net.yura.mobile.gui.layout.XULLoader;
+import net.yura.mobile.gui.plaf.MetalLookAndFeel;
+import net.yura.mobile.gui.plaf.nimbus.NimbusLookAndFeel;
+import net.yura.mobile.io.RMSUtil;
+import net.yura.mobile.util.SystemUtil;
+
+/**
+ * ALL test methods need to start with the word "test" and be public to work with android
+ * @author Yura Mamyrin
+ */
+public class JMUnitTest extends TestCase {
+
+ public JMUnitTest() {
+ //The first parameter of inherited constructor is the number of test cases
+ super(4, "JMUnitTest");
+ }
+
+ public void test(int testNumber) throws Throwable {
+
+ switch(testNumber) {
+ //case 0: testXULLoaderAdjustSizeToDensity(); break;
+ case 1: testRMSUtil(); break;
+ case 2: testSocketGet(); break;
+ case 3: testShowing(); break;
+ }
+
+ }
+/*
+ public void testXULLoaderAdjustSizeToDensity() {
+
+ // 36x36 for low-density
+ // 48x48 for medium-density
+ // 72x72 for high-density
+ // 96x96 for extra high-density
+
+ int source = 36;
+
+ XULLoader.setDPI("ldpi");
+ assertEquals(36, XULLoader.adjustSizeToDensity(source) );
+
+ XULLoader.setDPI("mdpi");
+ assertEquals(48, XULLoader.adjustSizeToDensity(source) );
+
+ XULLoader.setDPI("hdpi");
+ assertEquals(72, XULLoader.adjustSizeToDensity(source) );
+
+ XULLoader.setDPI("xhdpi");
+ assertEquals(96, XULLoader.adjustSizeToDensity(source) );
+
+ XULLoader.setDPI("tvdpi");
+ assertEquals(64, XULLoader.adjustSizeToDensity(source) );
+
+ XULLoader.setDPI(null); // should default to mdpi size
+ assertEquals(48, XULLoader.adjustSizeToDensity(source) );
+ }
+*/
+ public void testRMSUtil() throws Exception {
+
+ Hashtable obj = new Hashtable();
+ obj.put("tests", new Vector());
+ obj.put(new Integer(5), new Double(5.5));
+ obj.put(new Object[] {"String",new Integer(666)}, new Hashtable());
+
+
+ RMSUtil.save("Test1", obj);
+
+ Object obj2 = RMSUtil.load("Test1");
+
+ assertTrue( SystemUtil.equals(obj, obj2) );
+
+ }
+
+
+ public void testSocketGet() throws Exception {
+
+/*
+ StreamConnection socket = (StreamConnection)Connector.open("socket://google.com:80");
+ //Socket socket = SSLSocketFactory.getDefault().createSocket("google.com", 443 );
+ //Socket socket = SocketFactory.getDefault().createSocket("google.com", 80 );
+
+ String post = "GET / HTTP/1.0\r\n" + // 1.1 does not close the InputStream
+ "Host: google.com\r\n" +
+ "User-Agent: Mozilla/5.0 (Windows NT 5.2; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2\r\n" +
+ "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*\x80/*;q=0.8\r\n" +
+ // "Accept-Language: en-us,en;q=0.5\r\n" +
+ // "Accept-Encoding: gzip, deflate\r\n" +
+ // "Connection: keep-alive\r\n" +
+ // "Referer: http://yura.net/\r\n" +
+ "\r\n";
+
+ OutputStream out = socket.openOutputStream();
+ InputStream in = socket.openInputStream();
+
+ out.write( post.getBytes("ISO-8859-1") );
+ out.flush();
+
+ byte[] bytes = SystemUtil.getData(in, -1);
+
+ String result = new String(bytes,"ISO-8859-1");
+ System.out.println( result );
+*/
+
+ }
+
+ public void testShowing() {
+ System.out.println("testShowing start");
+
+ DesktopPane dp = new DesktopPane(null, -1, null);
+
+ dp.setLookAndFeel( new NimbusLookAndFeel() );
+
+ Button button = new Button();
+
+ assertFalse( button.isShowing() );
+
+ Panel panel = new Panel();
+ panel.add(button);
+
+ assertFalse( button.isShowing() );
+ assertFalse( panel.isShowing() );
+
+ Frame frame = new Frame();
+ frame.getContentPane().add(panel);
+
+ assertFalse( button.isShowing() );
+ assertFalse( panel.isShowing() );
+ assertFalse( frame.isShowing() );
+
+ frame.setVisible(true);
+
+ assertTrue( button.isShowing() );
+ assertTrue( panel.isShowing() );
+ assertTrue( frame.isShowing() );
+
+ panel.setVisible(false);
+
+ assertFalse( button.isShowing() );
+ assertFalse( panel.isShowing() );
+ assertTrue( frame.isShowing() );
+
+ panel.setVisible(true);
+ button.setVisible(false);
+
+ assertFalse( button.isShowing() );
+ assertTrue( panel.isShowing() );
+ assertTrue( frame.isShowing() );
+
+ button.setVisible(true);
+ frame.setVisible(false);
+
+ assertFalse( button.isShowing() );
+ assertFalse( panel.isShowing() );
+ assertFalse( frame.isShowing() );
+
+ System.out.println("testShowing done");
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|