Skip to content

Commit

Permalink
add adjusting flow template. And include it in the mouse templates.
Browse files Browse the repository at this point in the history
Remove constantSpeed from average user template.

update powermockito to 2.0.2
  • Loading branch information
JoonasVali committed Sep 8, 2019
1 parent 9a14f02 commit 18b7269
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
16 changes: 10 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@
</licenses>

<properties>
<java.version>1.8</java.version>
<java.version.source>1.8</java.version.source>
<java.version.target>1.8</java.version.target>
<maven.compiler.source>${java.version.source}</maven.compiler.source>
<maven.compiler.target>${java.version.target}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<powermock.version>2.0.2</powermock.version>
</properties>

<scm>
Expand All @@ -57,13 +61,13 @@
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.7.4</version>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.7.4</version>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -75,8 +79,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<source>${java.version.source}</source>
<target>${java.version.target}</target>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public DefaultSpeedManager() {
new Flow(FlowTemplates.interruptedFlow2()),
new Flow(FlowTemplates.slowStartupFlow()),
new Flow(FlowTemplates.slowStartup2Flow()),
new Flow(FlowTemplates.adjustingFlow()),
new Flow(FlowTemplates.jaggedFlow()),
new Flow(FlowTemplates.stoppingFlow())
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ public static MouseMotionFactory createGrannyMotionFactory() {
*/
public static MouseMotionFactory createGrannyMotionFactory(MouseMotionNature nature) {
MouseMotionFactory factory = new MouseMotionFactory(nature);
List<Flow> flows = new ArrayList<>();
flows.add(new Flow(FlowTemplates.jaggedFlow()));
flows.add(new Flow(FlowTemplates.random()));
flows.add(new Flow(FlowTemplates.interruptedFlow()));
flows.add(new Flow(FlowTemplates.interruptedFlow2()));
flows.add(new Flow(FlowTemplates.stoppingFlow()));
List<Flow> flows = new ArrayList<>(Arrays.asList(
new Flow(FlowTemplates.jaggedFlow()),
new Flow(FlowTemplates.random()),
new Flow(FlowTemplates.interruptedFlow()),
new Flow(FlowTemplates.interruptedFlow2()),
new Flow(FlowTemplates.adjustingFlow()),
new Flow(FlowTemplates.stoppingFlow())
));
DefaultSpeedManager manager = new DefaultSpeedManager(flows);
factory.setDeviationProvider(new SinusoidalDeviationProvider(9));
factory.setNoiseProvider(new DefaultNoiseProvider(1.6));
Expand Down Expand Up @@ -116,6 +118,7 @@ public static MouseMotionFactory createFastGamerMotionFactory(MouseMotionNature
new Flow(FlowTemplates.variatingFlow()),
new Flow(FlowTemplates.slowStartupFlow()),
new Flow(FlowTemplates.slowStartup2Flow()),
new Flow(FlowTemplates.adjustingFlow()),
new Flow(FlowTemplates.jaggedFlow())
));
DefaultSpeedManager manager = new DefaultSpeedManager(flows);
Expand Down Expand Up @@ -149,19 +152,20 @@ public static MouseMotionFactory createAverageComputerUserMotionFactory() {
public static MouseMotionFactory createAverageComputerUserMotionFactory(MouseMotionNature nature) {
MouseMotionFactory factory = new MouseMotionFactory(nature);
List<Flow> flows = new ArrayList<>(Arrays.asList(
new Flow(FlowTemplates.constantSpeed()),
new Flow(FlowTemplates.variatingFlow()),
new Flow(FlowTemplates.interruptedFlow()),
new Flow(FlowTemplates.interruptedFlow2()),
new Flow(FlowTemplates.slowStartupFlow()),
new Flow(FlowTemplates.slowStartup2Flow()),
new Flow(FlowTemplates.adjustingFlow()),
new Flow(FlowTemplates.jaggedFlow()),
new Flow(FlowTemplates.stoppingFlow())
));
DefaultSpeedManager manager = new DefaultSpeedManager(flows);
factory.setDeviationProvider(new SinusoidalDeviationProvider(SinusoidalDeviationProvider.DEFAULT_SLOPE_DIVIDER));
factory.setNoiseProvider(new DefaultNoiseProvider(DefaultNoiseProvider.DEFAULT_NOISINESS_DIVIDER));
manager.setMouseMovementBaseTimeMs(450);
factory.getNature().setReactionTimeVariationMs(110);
manager.setMouseMovementBaseTimeMs(400);

DefaultOvershootManager overshootManager = (DefaultOvershootManager) factory.getOvershootManager();
overshootManager.setOvershoots(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ public static double[] stoppingFlow() {
};
}

public static double[] adjustingFlow() {
return new double[] {
1, 1, 1, 3, 8, 7, 2, 2, 4, 8, 6, 3, 7, 13, 18, 19, 24, 35, 26, 14, 31,
43, 49, 55, 61, 67, 61, 50, 43, 37, 30, 16, 5, 4, 4, 3, 3, 3, 4, 4, 3,
2, 2, 3, 10, 14, 10, 7, 5, 5
};
}

public static double[] random() {
double[] result = new double[100];
for (int i = 0; i < result.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class ScreenAdjustedNatureDefaultsTest {
public void setup() throws Exception {
mouse = new MockMouse(60, 60);
DefaultSystemCalls mockSystemCalls = new MockSystemCalls(mouse, 800, 500);

whenNew(DefaultSystemCalls.class).withAnyArguments().thenReturn(mockSystemCalls);
whenNew(DefaultMouseInfoAccessor.class).withAnyArguments().thenReturn(mouse);

Expand Down

0 comments on commit 18b7269

Please sign in to comment.