From 63ee32313dc6a679ed418245b50debfe2b938656 Mon Sep 17 00:00:00 2001 From: bustardcelly Date: Wed, 5 Feb 2020 17:05:41 -0500 Subject: [PATCH 1/2] The test listing used a basic adapter to generate the views previously. However, the standard listing resource had an id that was duplicated for each list item. As such, it was impossible for appium to select items in the list. A custom list adapter has been created and assigns an accessibility id for aide in automated testing. --- **Affects internal Android testbed ONLY.** --- app/app.iml | 4 +- .../testandroidproject/TestListFragment.java | 41 +++++-------------- .../testandroidproject/tests/TestContent.java | 33 ++++----------- .../tests/TestItemAdapter.java | 39 ++++++++++++++++++ app/src/main/res/layout/test_list_item.xml | 11 +++++ 5 files changed, 70 insertions(+), 58 deletions(-) create mode 100644 app/src/main/java/red5pro/org/testandroidproject/tests/TestItemAdapter.java create mode 100644 app/src/main/res/layout/test_list_item.xml diff --git a/app/app.iml b/app/app.iml index 9edbefb..574add0 100644 --- a/app/app.iml +++ b/app/app.iml @@ -89,7 +89,7 @@ - + @@ -127,4 +127,4 @@ - + \ No newline at end of file diff --git a/app/src/main/java/red5pro/org/testandroidproject/TestListFragment.java b/app/src/main/java/red5pro/org/testandroidproject/TestListFragment.java index 1634c2e..dfa82b6 100644 --- a/app/src/main/java/red5pro/org/testandroidproject/TestListFragment.java +++ b/app/src/main/java/red5pro/org/testandroidproject/TestListFragment.java @@ -1,28 +1,3 @@ -// -// Copyright © 2015 Infrared5, Inc. All rights reserved. -// -// The accompanying code comprising examples for use solely in conjunction with Red5 Pro (the "Example Code") -// is licensed to you by Infrared5 Inc. in consideration of your agreement to the following -// license terms and conditions. Access, use, modification, or redistribution of the accompanying -// code constitutes your acceptance of the following license terms and conditions. -// -// Permission is hereby granted, free of charge, to you to use the Example Code and associated documentation -// files (collectively, the "Software") without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the following conditions: -// -// The Software shall be used solely in conjunction with Red5 Pro. Red5 Pro is licensed under a separate end -// user license agreement (the "EULA"), which must be executed with Infrared5, Inc. -// An example of the EULA can be found on our website at: https://account.red5pro.com/assets/LICENSE.txt. -// -// The above copyright notice and this license shall be included in all copies or portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT -// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL INFRARED5, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// package red5pro.org.testandroidproject; import android.app.Activity; @@ -34,6 +9,7 @@ import android.widget.ListView; import red5pro.org.testandroidproject.tests.TestContent; +import red5pro.org.testandroidproject.tests.TestItemAdapter; /** * A list fragment representing a list of Tests. This fragment @@ -101,12 +77,13 @@ public void onCreate(Bundle savedInstanceState) { //Load XML TESTS TestContent.LoadTests(res.openRawResource(R.raw.tests)); // TODO: replace with a real list adapter. + // AND DONE! see onViewCreated - setListAdapter(new ArrayAdapter( - getActivity(), - android.R.layout.simple_list_item_activated_1, - android.R.id.text1, - TestContent.ITEMS)); +// setListAdapter(new ArrayAdapter( +// getActivity(), +// android.R.layout.simple_list_item_activated_1, +// android.R.id.text1, +// TestContent.ITEMS)); } @Override @@ -118,6 +95,10 @@ public void onViewCreated(View view, Bundle savedInstanceState) { && savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) { setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION)); } + + // Added to be able to assign accessibility id for appium testing. + TestItemAdapter adapter = new TestItemAdapter(this.getActivity(), TestContent.ITEMS); + setListAdapter(adapter); } @Override diff --git a/app/src/main/java/red5pro/org/testandroidproject/tests/TestContent.java b/app/src/main/java/red5pro/org/testandroidproject/tests/TestContent.java index d3258c1..bc27987 100644 --- a/app/src/main/java/red5pro/org/testandroidproject/tests/TestContent.java +++ b/app/src/main/java/red5pro/org/testandroidproject/tests/TestContent.java @@ -1,32 +1,10 @@ -// -// Copyright © 2015 Infrared5, Inc. All rights reserved. -// -// The accompanying code comprising examples for use solely in conjunction with Red5 Pro (the "Example Code") -// is licensed to you by Infrared5 Inc. in consideration of your agreement to the following -// license terms and conditions. Access, use, modification, or redistribution of the accompanying -// code constitutes your acceptance of the following license terms and conditions. -// -// Permission is hereby granted, free of charge, to you to use the Example Code and associated documentation -// files (collectively, the "Software") without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the following conditions: -// -// The Software shall be used solely in conjunction with Red5 Pro. Red5 Pro is licensed under a separate end -// user license agreement (the "EULA"), which must be executed with Infrared5, Inc. -// An example of the EULA can be found on our website at: https://account.red5pro.com/assets/LICENSE.txt. -// -// The above copyright notice and this license shall be included in all copies or portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT -// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL INFRARED5, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// package red5pro.org.testandroidproject.tests; +import android.content.Context; import android.util.Log; +import android.widget.ArrayAdapter; + import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -75,7 +53,7 @@ public static void LoadTests(InputStream stream){ NodeList tests = doc.getDocumentElement().getElementsByTagName("Test"); for (int i = 0; i < tests.getLength() ; i++) { Element testElement = (Element)tests.item(i); - TestItem test = new TestItem( ""+i , testElement );//.getAttribute("title") , testElement.toString() ); + TestItem test = new TestItem(""+i , testElement );//.getAttribute("title") , testElement.toString() ); ITEMS.add( test ); } @@ -163,6 +141,7 @@ public static void SetTestItem( int id ) { public static class TestItem { public String id; + public String title; public String content; public String className; public String description; @@ -176,6 +155,7 @@ public TestItem( String _id, String _content) { public TestItem( String _id, Element contentXML) { id = _id; + title = contentXML.getAttribute("title"); content = contentXML.getElementsByTagName("name").item(0).getTextContent(); className = contentXML.getElementsByTagName("class").item(0).getTextContent(); description = contentXML.getElementsByTagName("description").item(0).getTextContent(); @@ -187,4 +167,5 @@ public String toString() { return content; } } + } diff --git a/app/src/main/java/red5pro/org/testandroidproject/tests/TestItemAdapter.java b/app/src/main/java/red5pro/org/testandroidproject/tests/TestItemAdapter.java new file mode 100644 index 0000000..61ffad6 --- /dev/null +++ b/app/src/main/java/red5pro/org/testandroidproject/tests/TestItemAdapter.java @@ -0,0 +1,39 @@ +package red5pro.org.testandroidproject.tests; + +import android.content.Context; +import android.content.res.Resources; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; + +import red5pro.org.testandroidproject.R; + +public class TestItemAdapter extends ArrayAdapter { + public TestItemAdapter(Context context, List tests) { + super(context, 0, tests); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + // Get the data item for this position + TestContent.TestItem test = getItem(position); + // Check if an existing view is being reused, otherwise inflate the view + if (convertView == null) { + convertView = LayoutInflater.from(getContext()).inflate(R.layout.test_list_item, parent, false); + } + // Lookup view for data population +// TextView title = (TextView) convertView.findViewWithTag("textfield"); + TextView title = (TextView) convertView.findViewById(R.id.txt); + // Populate the data into the template view using the data object + title.setText(test.content); + title.setContentDescription(test.title); + Resources res = title.getResources(); + // Return the completed view to render on screen + return convertView; + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/test_list_item.xml b/app/src/main/res/layout/test_list_item.xml new file mode 100644 index 0000000..cc1089a --- /dev/null +++ b/app/src/main/res/layout/test_list_item.xml @@ -0,0 +1,11 @@ + + \ No newline at end of file From 8c0499e09bf0c191307262e64b1f39f928389f6f Mon Sep 17 00:00:00 2001 From: bustardcelly Date: Wed, 5 Feb 2020 17:06:15 -0500 Subject: [PATCH 2/2] The test listing used a basic adapter to generate the views previously. However, the standard listing resource had an id that was duplicated for each list item. As such, it was impossible for appium to select items in the list. A custom list adapter has been created and assigns an accessibility id for aide in automated testing. --- **Affects internal Android testbed ONLY.** --- .../testandroidproject/TestListFragment.java | 25 +++++++++++++++++++ .../PublishCameraSwapBlinkTest.java | 25 +++++++++++++++++++ .../testandroidproject/tests/TestContent.java | 25 +++++++++++++++++++ .../tests/TestItemAdapter.java | 25 +++++++++++++++++++ 4 files changed, 100 insertions(+) diff --git a/app/src/main/java/red5pro/org/testandroidproject/TestListFragment.java b/app/src/main/java/red5pro/org/testandroidproject/TestListFragment.java index dfa82b6..2594c8a 100644 --- a/app/src/main/java/red5pro/org/testandroidproject/TestListFragment.java +++ b/app/src/main/java/red5pro/org/testandroidproject/TestListFragment.java @@ -1,3 +1,28 @@ +// +// Copyright © 2015 Infrared5, Inc. All rights reserved. +// +// The accompanying code comprising examples for use solely in conjunction with Red5 Pro (the "Example Code") +// is licensed to you by Infrared5 Inc. in consideration of your agreement to the following +// license terms and conditions. Access, use, modification, or redistribution of the accompanying +// code constitutes your acceptance of the following license terms and conditions. +// +// Permission is hereby granted, free of charge, to you to use the Example Code and associated documentation +// files (collectively, the "Software") without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The Software shall be used solely in conjunction with Red5 Pro. Red5 Pro is licensed under a separate end +// user license agreement (the "EULA"), which must be executed with Infrared5, Inc. +// An example of the EULA can be found on our website at: https://account.red5pro.com/assets/LICENSE.txt. +// +// The above copyright notice and this license shall be included in all copies or portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT +// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL INFRARED5, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// package red5pro.org.testandroidproject; import android.app.Activity; diff --git a/app/src/main/java/red5pro/org/testandroidproject/tests/PublishCameraSwapBlinkTest/PublishCameraSwapBlinkTest.java b/app/src/main/java/red5pro/org/testandroidproject/tests/PublishCameraSwapBlinkTest/PublishCameraSwapBlinkTest.java index 695328e..0e0b333 100644 --- a/app/src/main/java/red5pro/org/testandroidproject/tests/PublishCameraSwapBlinkTest/PublishCameraSwapBlinkTest.java +++ b/app/src/main/java/red5pro/org/testandroidproject/tests/PublishCameraSwapBlinkTest/PublishCameraSwapBlinkTest.java @@ -1,3 +1,28 @@ +// +// Copyright © 2015 Infrared5, Inc. All rights reserved. +// +// The accompanying code comprising examples for use solely in conjunction with Red5 Pro (the "Example Code") +// is licensed to you by Infrared5 Inc. in consideration of your agreement to the following +// license terms and conditions. Access, use, modification, or redistribution of the accompanying +// code constitutes your acceptance of the following license terms and conditions. +// +// Permission is hereby granted, free of charge, to you to use the Example Code and associated documentation +// files (collectively, the "Software") without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The Software shall be used solely in conjunction with Red5 Pro. Red5 Pro is licensed under a separate end +// user license agreement (the "EULA"), which must be executed with Infrared5, Inc. +// An example of the EULA can be found on our website at: https://account.red5pro.com/assets/LICENSE.txt. +// +// The above copyright notice and this license shall be included in all copies or portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT +// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL INFRARED5, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// package red5pro.org.testandroidproject.tests.PublishCameraSwapBlinkTest; import android.hardware.Camera; diff --git a/app/src/main/java/red5pro/org/testandroidproject/tests/TestContent.java b/app/src/main/java/red5pro/org/testandroidproject/tests/TestContent.java index bc27987..8ce23ac 100644 --- a/app/src/main/java/red5pro/org/testandroidproject/tests/TestContent.java +++ b/app/src/main/java/red5pro/org/testandroidproject/tests/TestContent.java @@ -1,3 +1,28 @@ +// +// Copyright © 2015 Infrared5, Inc. All rights reserved. +// +// The accompanying code comprising examples for use solely in conjunction with Red5 Pro (the "Example Code") +// is licensed to you by Infrared5 Inc. in consideration of your agreement to the following +// license terms and conditions. Access, use, modification, or redistribution of the accompanying +// code constitutes your acceptance of the following license terms and conditions. +// +// Permission is hereby granted, free of charge, to you to use the Example Code and associated documentation +// files (collectively, the "Software") without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The Software shall be used solely in conjunction with Red5 Pro. Red5 Pro is licensed under a separate end +// user license agreement (the "EULA"), which must be executed with Infrared5, Inc. +// An example of the EULA can be found on our website at: https://account.red5pro.com/assets/LICENSE.txt. +// +// The above copyright notice and this license shall be included in all copies or portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT +// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL INFRARED5, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// package red5pro.org.testandroidproject.tests; diff --git a/app/src/main/java/red5pro/org/testandroidproject/tests/TestItemAdapter.java b/app/src/main/java/red5pro/org/testandroidproject/tests/TestItemAdapter.java index 61ffad6..c9728bc 100644 --- a/app/src/main/java/red5pro/org/testandroidproject/tests/TestItemAdapter.java +++ b/app/src/main/java/red5pro/org/testandroidproject/tests/TestItemAdapter.java @@ -1,3 +1,28 @@ +// +// Copyright © 2015 Infrared5, Inc. All rights reserved. +// +// The accompanying code comprising examples for use solely in conjunction with Red5 Pro (the "Example Code") +// is licensed to you by Infrared5 Inc. in consideration of your agreement to the following +// license terms and conditions. Access, use, modification, or redistribution of the accompanying +// code constitutes your acceptance of the following license terms and conditions. +// +// Permission is hereby granted, free of charge, to you to use the Example Code and associated documentation +// files (collectively, the "Software") without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The Software shall be used solely in conjunction with Red5 Pro. Red5 Pro is licensed under a separate end +// user license agreement (the "EULA"), which must be executed with Infrared5, Inc. +// An example of the EULA can be found on our website at: https://account.red5pro.com/assets/LICENSE.txt. +// +// The above copyright notice and this license shall be included in all copies or portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT +// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL INFRARED5, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// package red5pro.org.testandroidproject.tests; import android.content.Context;