diff --git a/ElementTest.java b/ElementTest.java new file mode 100644 index 0000000..d971580 --- /dev/null +++ b/ElementTest.java @@ -0,0 +1,291 @@ +package org.aplas.myshop; + +import android.graphics.Typeface; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.GradientDrawable; +import android.view.View; +import android.widget.Adapter; +import android.widget.CheckBox; +import android.widget.LinearLayout; +import android.widget.RadioButton; +import android.widget.RelativeLayout; +import android.widget.Spinner; +import android.widget.TableLayout; +import android.widget.TextView; + +import java.util.List; + +public class ElementTest extends org.aplas.myshop.ViewTest { + private View component; + private String compName; + private String msgHeader; + private String className; + //private ArrayList testList = new ArrayList<>(); + + public ElementTest(View comp) { + component =comp; + compName = component.getContext().getResources().getResourceEntryName(component.getId()); + className = component.getClass().getSimpleName(); + msgHeader = "\n( "+compName+" - "+className+" ) "; + } + + public void testIdName(String expected) { + String msg = msgHeader + "Element Id Name is not suitable\n"; + testItem(expected,compName,msg,1); + } + + public void testWidth(int expected) { + String msg = msgHeader + "Element width is not suitable\n"; + testItem(expected,component.getLayoutParams().width,msg,1); + } + + public void testHeight(int expected) { + String msg = msgHeader + "Element height is not suitable\n"; + testItem(expected,component.getLayoutParams().height,msg,1); + } + + public void testWeight(float expected) { + String msg = msgHeader + "Element height is not suitable\n"; + testItem(expected,((LinearLayout.LayoutParams)component.getLayoutParams()).weight,msg,1); + } + + public void testOrientation(int expected) { + String msg = msgHeader + "Element orientation is not suitable\n"; + testItem(expected,((LinearLayout)component).getOrientation(),msg,1); + } + + public void testTopMargin(int expected) { + String msg = msgHeader + "Element top margin is not suitable\n"; + if (component.getLayoutParams().getClass().equals(RelativeLayout.LayoutParams.class)) { + testItem(expected,((RelativeLayout.LayoutParams)component.getLayoutParams()).topMargin,msg,1); + } else { + testItem(expected, ((LinearLayout.LayoutParams) component.getLayoutParams()).topMargin, msg, 1); + } + } + + public void testBottomMargin(int expected) { + String msg = msgHeader + "Element top margin is not suitable\n"; + if (component.getLayoutParams().getClass().equals(RelativeLayout.LayoutParams.class)) { + testItem(expected,((RelativeLayout.LayoutParams)component.getLayoutParams()).bottomMargin,msg,1); + } else { + testItem(expected, ((LinearLayout.LayoutParams) component.getLayoutParams()).bottomMargin, msg, 1); + } + } + + public void testPaddingLeft(int expected) { + String msg = msgHeader + "Element left padding is not suitable\n"; + testItem(expected,component.getPaddingLeft(),msg,1); + } + public void testPaddingRight(int expected) { + String msg = msgHeader + "Element right padding is not suitable\n"; + testItem(expected,component.getPaddingRight(),msg,1); + } + public void testPadding(int expected) { + String msg = msgHeader + "Element padding is not suitable\n"; + testItem(expected,component.getPaddingTop(),msg,1); + testItem(expected,component.getPaddingBottom(),msg,1); + testItem(expected,component.getPaddingLeft(),msg,1); + testItem(expected,component.getPaddingRight(),msg,1); + } + public void testBgColor(int expected) { + String msg = msgHeader + "Element Background color is not suitable\n"; + testItem(expected,((ColorDrawable) component.getBackground()).getColor(),msg,1); + } + + public void testBgGradientColor(int[] expected) { + String msg = msgHeader + "Element Background gradient color is not suitable\n"; + GradientDrawable draw = (GradientDrawable) component.getBackground(); + //draw.getColors() + testItem(expected[0],draw.getColors()[0],msg,1); + testItem(expected[1],draw.getColors()[1],msg,1); + testItem(expected[2],draw.getColors()[2],msg,1); + } + + public void testTextString(String expected) { + String msg = msgHeader + "Element text string is not suitable\n"; + testItem(expected,((TextView)component).getText().toString(),msg,1); + } + + public void testTextFace(Typeface expected) { + String msg = msgHeader + "Element text font is not suitable\n"; + testItem(expected,((TextView)component).getPaint().getTypeface(),msg,1); + } + + public void testTextStyle(int expected) { + String msg = msgHeader + "Element text style (bold/italic/normal) is not suitable\n"; + testItem(expected,((TextView)component).getPaint().getTypeface().getStyle(),msg,1); + } + + public void testTextColor(int expected) { + String msg = msgHeader + "Element text color is not suitable\n"; + testItem(expected,((TextView)component).getTextColors().getDefaultColor(),msg,1); + } + + public void testTextSize(float expected) { + String msg = msgHeader + "Element text size is not suitable\n"; + /*if (className.equals("AppCompatSpinner")) { + testItem(expected,((Spinner)component).get,msg,1); + }*/ + testItem(expected,((TextView)component).getTextSize(),msg,1); + } + + public void testGravity(int expected) { + String msg = msgHeader + "Element gravity orientation is not suitable\n"; + if (className.equals("AppCompatSpinner")) { + testItem(expected,((Spinner)component).getGravity(),msg,1); + } else if (className.equals("AppCompatTextView")) { + testItem(expected, ((TextView) component).getGravity(), msg, 1); + } else if (className.equals("TableLayout")) { + testItem(expected, ((LinearLayout)component).getGravity(), msg, 1); + } + } + + public void testAllCaps(boolean expected) { + String msg = msgHeader + "Element all caps is not suitable\n"; + testItem(expected,((TextView)component).isAllCaps(),msg,1); + } + + public void testHintText(String expected) { + String msg = msgHeader + "Element hint text is not suitable\n"; + testItem(expected,((TextView)component).getHint().toString(),msg,1); + } + + public void testInputType(int expected) { + String msg = msgHeader + "Element input type is not suitable\n"; + testItem(expected,((TextView)component).getInputType(),msg,1); + } + + public void testIsEnabled(boolean expected) { + String msg = msgHeader + "Element enabled value is not suitable\n"; + testItem(expected,component.isEnabled(),msg,1); + } + + public void testPromptText(String expected) { + String msg = msgHeader + "Element prompt text is not suitable\n"; + testItem(expected,((Spinner)component).getPrompt().toString(),msg,1); + } + + public void testSpinnerMode(int expected) { + String msg = msgHeader + "Element mode is not suitable\n"; + if (expected==0) { + testItem(expected,((Spinner)component).getDropDownVerticalOffset(),msg,1); + } else { + testItem(expected,((Spinner)component).getDropDownVerticalOffset()>0,msg,3); + } + } + + public void testSpinnerContent(List expected) { + String msg = msgHeader + "Element spinner content is not suitable\n"; + + Adapter list = ((Spinner)component).getAdapter(); + String res = ""; + for (int i=0; iTesting documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/GUIDE1-11/C2.01 Guide--.docx b/GUIDE1-11/C2.01 Guide--.docx new file mode 100644 index 0000000..730f0f6 Binary files /dev/null and b/GUIDE1-11/C2.01 Guide--.docx differ diff --git a/GUIDE1-11/C2.02 Guide--.docx b/GUIDE1-11/C2.02 Guide--.docx new file mode 100644 index 0000000..2366a9d Binary files /dev/null and b/GUIDE1-11/C2.02 Guide--.docx differ diff --git a/GUIDE1-11/C2.03 Guide--.docx b/GUIDE1-11/C2.03 Guide--.docx new file mode 100644 index 0000000..9b1ab06 Binary files /dev/null and b/GUIDE1-11/C2.03 Guide--.docx differ diff --git a/GUIDE1-11/C2.04 Guide--.docx b/GUIDE1-11/C2.04 Guide--.docx new file mode 100644 index 0000000..723081d Binary files /dev/null and b/GUIDE1-11/C2.04 Guide--.docx differ diff --git a/GUIDE1-11/C2.05 Guide--.docx b/GUIDE1-11/C2.05 Guide--.docx new file mode 100644 index 0000000..74248db Binary files /dev/null and b/GUIDE1-11/C2.05 Guide--.docx differ diff --git a/GUIDE1-11/C2.06 Guide--.docx b/GUIDE1-11/C2.06 Guide--.docx new file mode 100644 index 0000000..cfc324d Binary files /dev/null and b/GUIDE1-11/C2.06 Guide--.docx differ diff --git a/GUIDE1-11/C2.07 Guide--.docx b/GUIDE1-11/C2.07 Guide--.docx new file mode 100644 index 0000000..e96caae Binary files /dev/null and b/GUIDE1-11/C2.07 Guide--.docx differ diff --git a/GUIDE1-11/C2.08 Guide--.docx b/GUIDE1-11/C2.08 Guide--.docx new file mode 100644 index 0000000..ecf1ed5 Binary files /dev/null and b/GUIDE1-11/C2.08 Guide--.docx differ diff --git a/GUIDE1-11/C2.09 Guide--.docx b/GUIDE1-11/C2.09 Guide--.docx new file mode 100644 index 0000000..f5f939a Binary files /dev/null and b/GUIDE1-11/C2.09 Guide--.docx differ diff --git a/GUIDE1-11/C2.10 Guide--.docx b/GUIDE1-11/C2.10 Guide--.docx new file mode 100644 index 0000000..911a7d5 Binary files /dev/null and b/GUIDE1-11/C2.10 Guide--.docx differ diff --git a/GUIDE1-11/C2.11 Guide--.docx b/GUIDE1-11/C2.11 Guide--.docx new file mode 100644 index 0000000..c33a732 Binary files /dev/null and b/GUIDE1-11/C2.11 Guide--.docx differ diff --git a/GuideFiles.rar b/GuideFiles.rar deleted file mode 100644 index ee73e16..0000000 Binary files a/GuideFiles.rar and /dev/null differ diff --git a/ResourceTest.java b/ResourceTest.java new file mode 100644 index 0000000..b85897b --- /dev/null +++ b/ResourceTest.java @@ -0,0 +1,146 @@ +package org.aplas.myshop; + +import android.app.Activity; +import android.content.pm.ActivityInfo; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.res.Resources; + +import androidx.core.content.ContextCompat; + +import java.util.Arrays; + +public class ResourceTest extends org.aplas.myshop.ViewTest { + private Resources resource; + + public ResourceTest(Resources rsc) { + resource =rsc; + } + + public int getResourceId(String name, String type) { + return resource.getIdentifier(name, type, getClass().getPackage().getName()); + } + + public void testStringResource(String name) { + int resId = getResourceId(name,"string"); + testItem(0,resId,"String \'"+name+"\' is not defined in strings.xml of values resource",2); + } + + public void testStringResource(String name, String expected) { + int resId = resource.getIdentifier(name, "string", getClass().getPackage().getName()); + testItem(0,resId,"String \'"+name+"\' is not defined in strings.xml of values resource",2); + testItem(expected,resource.getString(resId),"Value of string \'"+name+"\' is not valid",1); + } + + public void testIntegerResource(String name, int expected) { + int resId = resource.getIdentifier(name, "integer", getClass().getPackage().getName()); + testItem(0,resId,"Integer "+name+" id is not exist",2); + testItem(expected,resource.getString(resId),"Integer "+name+" value is not valid",1); + } + + public void testStringArrayResource(String name, String[] expected) { + int resId = resource.getIdentifier(name, "array", getClass().getPackage().getName()); + testItem(0,resId,"String array \'"+name+"\' is not defined in strings.xml of values resource",2); + String[] str = resource.getStringArray(resId); + testItem(arrayToString(expected),arrayToString(str),"Value of String array \'"+name+"\' is not valid",1); + } + + public void testColorResource(Activity activity, String name, String value) { + int resId = resource.getIdentifier(name, "color", getClass().getPackage().getName()); + testItem(0,resId,"Color '"+name+"' is not defined in colors.xml of value resource",2); + int clrVal = ContextCompat.getColor(activity, resId); + //testItem(Color.parseColor(value),clrVal,"Color '"+name+"' value should be '"+value+"'",1); + testItem(value.toUpperCase(),getHexColor(clrVal),"Color '"+name+"' value should be '"+value+"'",1); + } + + public void testColorArrayResource(String name, String[] expected) { + int resId = resource.getIdentifier(name, "array", getClass().getPackage().getName()); + testItem(0,resId,"Color array \'"+name+"\' is not defined in colors.xml of values resource",2); + int[] str = resource.getIntArray(resId); + testItem(arrayToString(expected),colorArrayToString(str), + "Value of Color array \'"+name+"\' is not valid in colors.xml resource",1); + } + + public void testFontResource(String name, String expected) { + //int resId = R.font.cambria; + //Typeface font = Typeface.createFromAsset(resource.getAssets(),name); + int resId = resource.getIdentifier(name, "font", getClass().getPackage().getName()); + testItem(0,resId,"Font "+name+" id is not exist",2); + testItem(expected,resource.getResourceEntryName(resId),"Font "+name+" value is not valid",1); + } + + public void testImgResource(String name) { + int resId = resource.getIdentifier(name, "drawable", getClass().getPackage().getName()); + testItem(0,resId,"Image "+name+".(png/jpg) is not exist in drawable resource ",2); + } + + public void testImgAnimationResource(String name) { + int resId = resource.getIdentifier(name, "drawable", getClass().getPackage().getName()); + testItem(0,resId,"Image animation "+name+".xml is not exist in drawable resource ",2); + } + + public void testViewAnimationResource(String name) { + int resId = resource.getIdentifier(name, "anim", getClass().getPackage().getName()); + testItem(0,resId,"View animation "+name+".xml is not exist in anim resource ",2); + } + + public void testDrawableResource(String name, String expected) { + int resId = resource.getIdentifier(name, "drawable", getClass().getPackage().getName()); + testItem(0,resId,"Drawable "+name+" id is not exist",2); + //testItem(expected,resource.getDrawable(resId).,"Drawable "+expected+" value is not valid",1); + } + + public void testStyleResource(String name) { + int resId = resource.getIdentifier(name, "style", getClass().getPackage().getName()); + testItem(0,resId,"Style '"+name+"' is not exist in styles.xml",2); + } + + public void testVideoResource(String name) { + int resId = resource.getIdentifier(name, "raw", getClass().getPackage().getName()); + testItem(0,resId,"Video '"+name+".(mp4/mpg)' is not exist in raw folder of resource",2); + } + + public void testAppTheme(Activity activity, String name) { + int resId = resource.getIdentifier(name, "style", getClass().getPackage().getName()); + testItem(resId,activity.getApplicationInfo().theme, + "Applied theme in AndroidManifest.xml should be \'@style/"+name+"\'",1); + } + + public void testAppPermission(Activity activity, String name) { + try { + PackageInfo info = activity.getPackageManager().getPackageInfo(activity.getPackageName(), PackageManager.GET_PERMISSIONS); + String[] permissions = info.requestedPermissions; + + testItem(0,permissions.length>0,"Can't find 'uses-permission' in AndroidManifest.xml file",3); + int x = Arrays.asList(permissions).indexOf(name); + testItem(0, x>=0, "AndroidManifest.xml must contain permission value '"+name+"'\n"+ + "put ",3); + } catch (Exception e) { + testItem(0,0,"Permission value in AndroidManifest.xml error",2); + } + } + + public void testAppActivities(Activity activity, String name, String packName) { + //testItem(0,activity.getPackageManager().getLaunchIntentForPackage(packName+"."+name), + // "Activity "+name+" must be LAUNCHER",6); + + try { + PackageInfo info = activity.getPackageManager().getPackageInfo(activity.getPackageName(), PackageManager.GET_INTENT_FILTERS); + ActivityInfo[] activities = info.activities; + + String res=""; + for (int i=0; i0,"Can't find 'uses-permission' in AndroidManifest.xml file",3); + //int x = Arrays.asList(permissions).indexOf(name); + //testItem(0, x>=0, "AndroidManifest.xml must contain permission value '"+name+"'\n"+ + // "put ",3); + } catch (Exception e) { + testItem(0,0,"Permission value in AndroidManifest.xml error"+e.toString(),2); + } + } + + +} diff --git a/Suplement File/item_buyer_product_recycler.xml b/Suplement File/item_buyer_product_recycler.xml new file mode 100644 index 0000000..05befe8 --- /dev/null +++ b/Suplement File/item_buyer_product_recycler.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Suplement File/item_cart_recycler.xml b/Suplement File/item_cart_recycler.xml new file mode 100644 index 0000000..afd914c --- /dev/null +++ b/Suplement File/item_cart_recycler.xml @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Suplement File/item_product_recycler.xml b/Suplement File/item_product_recycler.xml new file mode 100644 index 0000000..91e4126 --- /dev/null +++ b/Suplement File/item_product_recycler.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + +