This repository has been archived by the owner on Aug 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2145982
commit ec78bc9
Showing
45 changed files
with
3,864 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
Smartphone/src/androidTest/java/eu/power_switch/obj/ReceiverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* PowerSwitch by Max Rosin & Markus Ressel | ||
* Copyright (C) 2015 Markus Ressel | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package eu.power_switch.obj; | ||
|
||
import eu.power_switch.ApplicationTest; | ||
import eu.power_switch.obj.gateway.BrematicGWY433; | ||
import eu.power_switch.obj.gateway.ConnAir; | ||
import eu.power_switch.obj.gateway.Gateway; | ||
import eu.power_switch.obj.gateway.ITGW433; | ||
|
||
/** | ||
* Created by Markus on 07.03.2016. | ||
*/ | ||
public abstract class ReceiverTest extends ApplicationTest { | ||
|
||
protected static Gateway connAir = new ConnAir((long) 0, true, "Gateway", "v0.1", "address", 0); | ||
protected static Gateway itgw = new ITGW433((long) 0, true, "Gateway", "v0.1", "address", 0); | ||
protected static Gateway brematicGWY433 = new BrematicGWY433((long) 0, true, "Gateway", "v0.1", "address", 0); | ||
|
||
protected Gateway[] gateways = new Gateway[]{connAir, itgw, brematicGWY433}; | ||
|
||
protected Class<?>[] argClassesGetSignal = new Class[]{Gateway.class, String.class}; | ||
|
||
} |
177 changes: 177 additions & 0 deletions
177
Smartphone/src/androidTest/java/eu/power_switch/obj/device/bat/RC3500_A_IP44_DE_Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
/* | ||
* PowerSwitch by Max Rosin & Markus Ressel | ||
* Copyright (C) 2015 Markus Ressel | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package eu.power_switch.obj.device.bat; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.LinkedList; | ||
|
||
import eu.power_switch.R; | ||
import eu.power_switch.obj.ReceiverTest; | ||
import eu.power_switch.obj.receiver.device.bat.RC3500_A_IP44_DE; | ||
|
||
/** | ||
* Created by Markus on 08.08.2015. | ||
*/ | ||
public class RC3500_A_IP44_DE_Test extends ReceiverTest { | ||
|
||
private static RC3500_A_IP44_DE receiver; | ||
|
||
@Test | ||
public void testCodeGeneration0000000000() throws Exception { | ||
LinkedList<Boolean> dips = new LinkedList<>(); | ||
dips.add(false); // 1 | ||
dips.add(false); // 2 | ||
dips.add(false); // 3 | ||
dips.add(false); // 4 | ||
dips.add(false); // 5 | ||
|
||
dips.add(false); // A | ||
dips.add(false); // B | ||
dips.add(false); // C | ||
dips.add(false); // D | ||
dips.add(false); // E | ||
|
||
receiver = new RC3500_A_IP44_DE(getContext(), (long) 0, "Name", dips, (long) 0); | ||
|
||
Method method = receiver.getClass().getDeclaredMethod("getSignal", argClassesGetSignal); | ||
method.setAccessible(true); | ||
Object[] argObjects = new Object[]{connAir, getContext().getString(R.string.on)}; | ||
String generatedMessage = (String) method.invoke(receiver, argObjects); | ||
|
||
// ON | ||
String expectedMessage = "TXP:0,0,10,5600,350,25,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,1,3,1,3,3,1,1,14;"; | ||
Assert.assertEquals(expectedMessage, generatedMessage); | ||
|
||
argObjects = new Object[]{connAir, getContext().getString(R.string.off)}; | ||
generatedMessage = (String) method.invoke(receiver, argObjects); | ||
|
||
// OFF | ||
expectedMessage = "TXP:0,0,10,5600,350,25,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,1,3,1,14;"; | ||
Assert.assertEquals(expectedMessage, generatedMessage); | ||
} | ||
|
||
@Test | ||
public void testCodeGeneration1000000000() throws Exception { | ||
LinkedList<Boolean> dips = new LinkedList<>(); | ||
dips.add(true); // 1 | ||
dips.add(false); // 2 | ||
dips.add(false); // 3 | ||
dips.add(false); // 4 | ||
dips.add(false); // 5 | ||
|
||
dips.add(false); // A | ||
dips.add(false); // B | ||
dips.add(false); // C | ||
dips.add(false); // D | ||
dips.add(false); // E | ||
|
||
receiver = new RC3500_A_IP44_DE(getContext(), (long) 0, "Name", dips, (long) 0); | ||
|
||
String methodName = "getSignal"; | ||
Method method = receiver.getClass().getDeclaredMethod(methodName, argClassesGetSignal); | ||
method.setAccessible(true); | ||
Object[] argObjects = new Object[]{connAir, getContext().getString(R.string.on)}; | ||
String generatedMessage = (String) method.invoke(receiver, argObjects); | ||
|
||
// ON | ||
String expectedMessage = "TXP:0,0,10,5600,350,25,1,3,1,3,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,1,3,1,3,3,1,1,14;"; | ||
Assert.assertEquals(expectedMessage, generatedMessage); | ||
|
||
argObjects = new Object[]{connAir, getContext().getString(R.string.off)}; | ||
generatedMessage = (String) method.invoke(receiver, argObjects); | ||
|
||
// OFF | ||
expectedMessage = "TXP:0,0,10,5600,350,25,1,3,1,3,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,1,3,1,14;"; | ||
Assert.assertEquals(expectedMessage, generatedMessage); | ||
} | ||
|
||
@Test | ||
public void testCodeGeneration1000010000() throws Exception { | ||
LinkedList<Boolean> dips = new LinkedList<>(); | ||
dips.add(true); // 1 | ||
dips.add(false); // 2 | ||
dips.add(false); // 3 | ||
dips.add(false); // 4 | ||
dips.add(false); // 5 | ||
|
||
dips.add(true); // A | ||
dips.add(false); // B | ||
dips.add(false); // C | ||
dips.add(false); // D | ||
dips.add(false); // E | ||
|
||
receiver = new RC3500_A_IP44_DE(getContext(), (long) 0, "Name", dips, (long) 0); | ||
|
||
String methodName = "getSignal"; | ||
Method method = receiver.getClass().getDeclaredMethod(methodName, argClassesGetSignal); | ||
method.setAccessible(true); | ||
Object[] argObjects = new Object[]{connAir, getContext().getString(R.string.on)}; | ||
String generatedMessage = (String) method.invoke(receiver, argObjects); | ||
|
||
// ON | ||
String expectedMessage = "TXP:0,0,10,5600,350,25,1,3,1,3,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,1,3,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,1,3,1,3,3,1,1,14;"; | ||
Assert.assertEquals(expectedMessage, generatedMessage); | ||
|
||
argObjects = new Object[]{connAir, getContext().getString(R.string.off)}; | ||
generatedMessage = (String) method.invoke(receiver, argObjects); | ||
|
||
// OFF | ||
expectedMessage = "TXP:0,0,10,5600,350,25,1,3,1,3,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,1,3,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,1,3,1,14;"; | ||
Assert.assertEquals(expectedMessage, generatedMessage); | ||
} | ||
|
||
@Test | ||
public void testCodeGeneration1111111111() throws Exception { | ||
LinkedList<Boolean> dips = new LinkedList<>(); | ||
dips.add(true); // 1 | ||
dips.add(true); // 2 | ||
dips.add(true); // 3 | ||
dips.add(true); // 4 | ||
dips.add(true); // 5 | ||
|
||
dips.add(true); // A | ||
dips.add(true); // B | ||
dips.add(true); // C | ||
dips.add(true); // D | ||
dips.add(true); // E | ||
|
||
receiver = new RC3500_A_IP44_DE(getContext(), (long) 0, "Name", dips, (long) 0); | ||
|
||
String methodName = "getSignal"; | ||
Method method = receiver.getClass().getDeclaredMethod(methodName, argClassesGetSignal); | ||
method.setAccessible(true); | ||
Object[] argObjects = new Object[]{connAir, getContext().getString(R.string.on)}; | ||
String generatedMessage = (String) method.invoke(receiver, argObjects); | ||
|
||
// ON | ||
String expectedMessage = "TXP:0,0,10,5600,350,25,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,3,1,1,14;"; | ||
Assert.assertEquals(expectedMessage, generatedMessage); | ||
|
||
argObjects = new Object[]{connAir, getContext().getString(R.string.off)}; | ||
generatedMessage = (String) method.invoke(receiver, argObjects); | ||
|
||
// OFF | ||
expectedMessage = "TXP:0,0,10,5600,350,25,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,3,1,1,3,1,3,1,14;"; | ||
Assert.assertEquals(expectedMessage, generatedMessage); | ||
} | ||
|
||
} |
Oops, something went wrong.