public void ToStringInvalidProtocol() { var spec = new ForwardSpec(); spec.Protocol = (ForwardProtocol)99; Assert.Equal(string.Empty, spec.ToString()); }
public void GetHashCode_CalculatesHashCode(string spec1, string spec2) { var forwardSpec1 = ForwardSpec.Parse(spec1); var forwardSpec1bis = ForwardSpec.Parse(spec1); var forwardSpec2 = ForwardSpec.Parse(spec2); Assert.Equal(forwardSpec1.GetHashCode(), forwardSpec1bis.GetHashCode()); Assert.NotEqual(forwardSpec1.GetHashCode(), forwardSpec2.GetHashCode()); }
public void ToString_ReturnsStringRepresentation() { var forward = new ForwardData() { LocalSpec = ForwardSpec.Parse("tcp:4"), RemoteSpec = ForwardSpec.Parse("tcp:5"), SerialNumber = "1245", }; Assert.Equal("1245 tcp:4 tcp:5", forward.ToString()); }
/// <summary> /// Create foward port /// </summary> /// <param name="minitouchport"></param> public void CreateForward(string localport, string remoteport) { try { client.CreateForward(selectedDevice, ForwardSpec.Parse(localport), ForwardSpec.Parse(remoteport), true); Console.Out.WriteLine("Forward Success"); } catch { } }
public void TcpTest() { var value = ForwardSpec.Parse("tcp:1234"); Assert.NotNull(value); Assert.Equal(ForwardProtocol.Tcp, value.Protocol); Assert.Equal(1234, value.Port); Assert.Equal(0, value.ProcessId); Assert.Null(value.SocketName); Assert.Equal("tcp:1234", value.ToString()); }
public void SocketText() { var value = ForwardSpec.Parse("localabstract:/tmp/1234"); Assert.NotNull(value); Assert.Equal(ForwardProtocol.LocalAbstract, value.Protocol); Assert.Equal(0, value.Port); Assert.Equal(0, value.ProcessId); Assert.Equal("/tmp/1234", value.SocketName); Assert.Equal("localabstract:/tmp/1234", value.ToString()); }
public void JdwpTest() { var value = ForwardSpec.Parse("jdwp:1234"); Assert.NotNull(value); Assert.Equal(ForwardProtocol.JavaDebugWireProtocol, value.Protocol); Assert.Equal(0, value.Port); Assert.Equal(1234, value.ProcessId); Assert.Null(value.SocketName); Assert.Equal("jdwp:1234", value.ToString()); }
public void Parse_ParsesSpecification(string input, ForwardProtocol protocol, int port, string socketName, int processId) { var value = ForwardSpec.Parse(input); Assert.NotNull(value); Assert.Equal(protocol, value.Protocol); Assert.Equal(port, value.Port); Assert.Equal(processId, value.ProcessId); Assert.Equal(socketName, value.SocketName); Assert.Equal(input, value.ToString()); }
public void Forward(int port) { var localSpec = new ForwardSpec { Protocol = ForwardProtocol.Tcp, Port = port }; var remoteSpec = new ForwardSpec { Protocol = ForwardProtocol.LocalAbstract, SocketName = "Unity-" + GlobalData.Instance.AndroidPackageName }; port = m_client.CreateForward(m_deviceData, localSpec, remoteSpec, true); if (port == 0) { return; } MessageBox.Show($"Forward : {port}"); }
public void EqualsTest() { var dummy = new ForwardSpec() { Protocol = (ForwardProtocol)99 }; var tcpa1 = ForwardSpec.Parse("tcp:1234"); var tcpa2 = ForwardSpec.Parse("tcp:1234"); var tcpb = ForwardSpec.Parse("tcp:4321"); Assert.True(tcpa1.Equals(tcpa2)); Assert.False(tcpa1.Equals(tcpb)); Assert.True(tcpa1.GetHashCode() == tcpa2.GetHashCode()); Assert.False(tcpa1.GetHashCode() == tcpb.GetHashCode()); var jdwpa1 = ForwardSpec.Parse("jdwp:1234"); var jdwpa2 = ForwardSpec.Parse("jdwp:1234"); var jdwpb = ForwardSpec.Parse("jdwp:4321"); Assert.True(jdwpa1.Equals(jdwpa2)); Assert.False(jdwpa1.Equals(jdwpb)); Assert.True(jdwpa1.GetHashCode() == jdwpa2.GetHashCode()); Assert.False(jdwpa1.GetHashCode() == jdwpb.GetHashCode()); var socketa1 = ForwardSpec.Parse("localabstract:/tmp/1234"); var socketa2 = ForwardSpec.Parse("localabstract:/tmp/1234"); var socketb = ForwardSpec.Parse("localabstract:/tmp/4321"); Assert.True(socketa1.Equals(socketa2)); Assert.False(socketa1.Equals(socketb)); Assert.True(socketa1.GetHashCode() == socketa2.GetHashCode()); Assert.False(socketa1.GetHashCode() == socketb.GetHashCode()); Assert.False(tcpa1.Equals(null)); Assert.False(tcpa1.Equals(dummy)); Assert.False(dummy.Equals(tcpa1)); Assert.False(tcpa1.Equals(jdwpa1)); Assert.False(tcpa1.Equals(socketa1)); Assert.False(tcpa1.GetHashCode() == dummy.GetHashCode()); Assert.False(tcpa1.GetHashCode() == jdwpa1.GetHashCode()); Assert.False(tcpa1.GetHashCode() == socketa1.GetHashCode()); }
public void Equals_ComparesForwardSpecifications(string spec1, string spec2) { var forwardSpec1 = ForwardSpec.Parse(spec1); var forwardSpec1bis = ForwardSpec.Parse(spec1); var forwardSpec2 = ForwardSpec.Parse(spec2); Assert.Equal(forwardSpec1, forwardSpec1bis); Assert.NotEqual(forwardSpec1, forwardSpec2); var dummy = new ForwardSpec() { Protocol = (ForwardProtocol)99, }; Assert.NotEqual(dummy, forwardSpec1); Assert.NotEqual(dummy, forwardSpec2); Assert.False(forwardSpec1.Equals(null)); Assert.False(forwardSpec2.Equals(null)); }
public void Parse_InvalidSpec(string spec) { Assert.Throws <ArgumentOutOfRangeException>(() => ForwardSpec.Parse(spec)); }
public void ParseInvalidProcessIdTest() { Assert.Throws <ArgumentOutOfRangeException>(() => ForwardSpec.Parse("jdwp:abc")); }
public void ParseInvalidProtocolTest() { Assert.Throws <ArgumentOutOfRangeException>(() => ForwardSpec.Parse("xyz:1234")); }
public void ParseNullTest() { Assert.Throws <ArgumentNullException>(() => ForwardSpec.Parse(null)); }
public void ParseInvalidTcpPortTest() { Assert.Throws <ArgumentOutOfRangeException>(() => ForwardSpec.Parse("tcp:xyz")); }
public void ParseInvalidTest() { ForwardSpec.Parse("abc"); }
public void ParseNullTest() { ForwardSpec.Parse(null); }
public void ParseInvalidTcpPortTest() { ForwardSpec.Parse("tcp:xyz"); }
public void CreateForward(DeviceData device, ForwardSpec local, ForwardSpec remote, bool allowRebind) { throw new NotImplementedException(); }
/// <summary> /// Connect minitouch /// </summary> public static void ConnectMinitouch([CallerLineNumber] int lineNumber = 0, [CallerMemberName] string caller = null) { try { if (AdbInstance.Instance.minitouchSocket != null) { AdbInstance.Instance.minitouchSocket = null; } } catch { } Thread.Sleep(100); try { var path = Path.GetTempPath() + "minitouch"; if (File.Exists(path)) { var ports = File.ReadAllLines(path); foreach (var tmp in ports) { foreach (var port in ports) { if (AdbInstance.Instance.minitouchPort == Convert.ToInt32(port)) { AdbInstance.Instance.minitouchPort++; } else { break; } } } } using (var stream = File.AppendText(path)) { stream.WriteLine(AdbInstance.Instance.minitouchPort); //Let other instance know that this socket is in use! } } catch { } if (!ScriptRun.Run) { return; } Variables.AdvanceLog("Connecting Minitouch", lineNumber, caller); string rndMiniTouch = Path.GetRandomFileName(); ConsoleOutputReceiver receiver = new ConsoleOutputReceiver(); try { AdbInstance.Instance.client.ExecuteRemoteCommand("find /data/local/tmp/ -maxdepth 1 -type f -delete", (Variables.Controlled_Device as DeviceData), receiver); } catch { Variables.AdvanceLog("Unable to delete temp minitouch file, will try at next round!"); } BotCore.Push(Environment.CurrentDirectory + "//adb//minitouch", "/data/local/tmp/" + rndMiniTouch, 777); try { int error = 0; while (Variables.Controlled_Device == null && ScriptRun.Run) { error++; Thread.Sleep(1000); foreach (var device in AdbInstance.Instance.client.GetDevices()) { Variables.AdvanceLog(device.ToString(), lineNumber, caller); if (device.ToString() == Variables.AdbIpPort) { Variables.Controlled_Device = device; Variables.DeviceChanged = true; Variables.AdvanceLog("Device found, connection establish on " + Variables.AdbIpPort, lineNumber, caller); break; } } if (error > 30) { RestartEmulator(); error = 0; } } if (!ScriptRun.Run) { return; } Cm: AdbInstance.Instance.client.ExecuteRemoteCommandAsync("/data/local/tmp/" + rndMiniTouch, (Variables.Controlled_Device as DeviceData), receiver, CancellationToken.None); AdbInstance.Instance.client.CreateForward((Variables.Controlled_Device as DeviceData), ForwardSpec.Parse($"tcp:{AdbInstance.Instance.minitouchPort}"), ForwardSpec.Parse("localabstract:minitouch"), true); AdbInstance.Instance.minitouchSocket = new TcpSocket(); AdbInstance.Instance.minitouchSocket.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), AdbInstance.Instance.minitouchPort)); if (AdbInstance.Instance.minitouchSocket.Connected) { try { string cmd = "d 0 0 0 100\nc\nu 0\nc\n"; byte[] bytes = AdbClient.Encoding.GetBytes(cmd); AdbInstance.Instance.minitouchSocket.Send(bytes, 0, bytes.Length, SocketFlags.None); } catch { Variables.AdvanceLog("Socket disconnected, retrying...", lineNumber, caller); goto Cm; } Variables.AdvanceLog("Minitouch connected on Port number " + AdbInstance.Instance.minitouchPort, lineNumber, caller); } else { Variables.AdvanceLog("Socket disconnected, retrying...", lineNumber, caller); EjectSockets(); AdbInstance.Instance.minitouchPort++; goto Cm; } } catch (Exception ex) { if (ex is AdbException) { AdbInstance.Instance.server.RestartServer(); RestartEmulator(); AdbInstance.Instance.minitouchPort = 1111; return; } Variables.AdvanceLog(ex.ToString(), lineNumber, caller); EjectSockets(); AdbInstance.Instance.minitouchPort++; ConnectMinitouch(); } Variables.DirectXCapt = Variables.emulator.DXScreen(); }
public void ParseInvalidProcessIdTest() { ForwardSpec.Parse("jdwp:abc"); }
public void ParseInvalidProtocolTest() { ForwardSpec.Parse("xyz:1234"); }