diff --git a/SharpAdbClient.Tests/DummyAdbSocket.cs b/SharpAdbClient.Tests/DummyAdbSocket.cs index e5a12155..b474ecfc 100644 --- a/SharpAdbClient.Tests/DummyAdbSocket.cs +++ b/SharpAdbClient.Tests/DummyAdbSocket.cs @@ -189,10 +189,7 @@ public void Read(byte[] data, int length) Assert.AreEqual(actual.Length, length); - for (int i = 0; i < length; i++) - { - data[i] = actual[i]; - } + Buffer.BlockCopy(actual, 0, data, 0, length); } public void SendSyncRequest(SyncCommand command, string path) @@ -240,7 +237,14 @@ public Task ReadAsync(byte[] data, int length, CancellationToken cancellati public void Send(byte[] data, int offset, int length) { - throw new NotImplementedException(); + if (offset == 0) + { + this.Send(data, length); + } + else + { + throw new NotImplementedException(); + } } } } diff --git a/SharpAdbClient.Tests/SocketBasedTests.cs b/SharpAdbClient.Tests/SocketBasedTests.cs index aed143bf..2a8fb7f3 100644 --- a/SharpAdbClient.Tests/SocketBasedTests.cs +++ b/SharpAdbClient.Tests/SocketBasedTests.cs @@ -296,6 +296,12 @@ protected static IEnumerable> SyncRequests(SyncComman yield return new Tuple(command, path); } + protected static IEnumerable> SyncRequests(SyncCommand command, string path, SyncCommand command2, string path2) + { + yield return new Tuple(command, path); + yield return new Tuple(command2, path2); + } + protected static IEnumerable> SyncRequests(SyncCommand command, string path, SyncCommand command2, string path2, SyncCommand command3, string path3) { yield return new Tuple(command, path); diff --git a/SharpAdbClient.Tests/SyncServiceTests.cs b/SharpAdbClient.Tests/SyncServiceTests.cs index df44de1a..3af3243f 100644 --- a/SharpAdbClient.Tests/SyncServiceTests.cs +++ b/SharpAdbClient.Tests/SyncServiceTests.cs @@ -127,16 +127,18 @@ public void PullTest() MemoryStream stream = new MemoryStream(); var content = File.ReadAllBytes("fstab.bin"); + var contentLength = BitConverter.GetBytes(content.Length); this.RunTest( OkResponses(2), ResponseMessages(), Requests("host:transport:169.254.109.177:5555", "sync:"), - SyncRequests(SyncCommand.RECV, "/fstab.donatello"), - new SyncCommand[] { SyncCommand.DATA, SyncCommand.DONE }, + SyncRequests(SyncCommand.STAT, "/fstab.donatello").Union(SyncRequests(SyncCommand.RECV, "/fstab.donatello")), + new SyncCommand[] { SyncCommand.STAT, SyncCommand.DATA, SyncCommand.DONE }, new byte[][] { - new byte[] {85, 2, 0, 0}, + new byte[] { 160, 129, 0, 0, 85, 2, 0, 0, 0, 0, 0, 0 }, + contentLength, content }, null, @@ -164,6 +166,10 @@ public void PushTest() Stream stream = File.OpenRead("fstab.bin"); var content = File.ReadAllBytes("fstab.bin"); + var contentMessage = new List(); + contentMessage.AddRange(SyncCommandConverter.GetBytes(SyncCommand.DATA)); + contentMessage.AddRange(BitConverter.GetBytes(content.Length)); + contentMessage.AddRange(content); this.RunTest( OkResponses(2), @@ -171,13 +177,12 @@ public void PushTest() Requests("host:transport:169.254.109.177:5555", "sync:"), SyncRequests( SyncCommand.SEND, "/sdcard/test,644", - SyncCommand.DATA, content.Length.ToString(), SyncCommand.DONE, "1446505200"), new SyncCommand[] { SyncCommand.OKAY }, null, new byte[][] { - content + contentMessage.ToArray() }, () => {