Skip to content

Commit

Permalink
Merge pull request quamotion#107 from pbielinski/master
Browse files Browse the repository at this point in the history
Update DeviceData.cs
  • Loading branch information
qmfrederik authored Dec 11, 2017
2 parents 8b8979f + 94d6a02 commit 9719f5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions SharpAdbClient.Tests/DeviceDataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,19 @@ public void GetStateFromStringTest()
Assert.AreEqual(DeviceState.NoPermissions, DeviceData.GetStateFromString("no permissions"));
Assert.AreEqual(DeviceState.Unknown, DeviceData.GetStateFromString("hello"));
}

[TestMethod]
public void CreateFromDeviceDataTransportIdTest()
{
string data = "R32D102SZAE device transport_id:6";

var device = DeviceData.CreateFromAdbData(data);
Assert.AreEqual<string>("R32D102SZAE", device.Serial);
Assert.AreEqual<string>("", device.Product);
Assert.AreEqual<string>("", device.Model);
Assert.AreEqual<string>("", device.Name);
Assert.AreEqual<DeviceState>(DeviceState.Online, device.State);
Assert.AreEqual(string.Empty, device.Usb);
}
}
}
2 changes: 1 addition & 1 deletion SharpAdbClient/DeviceData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class DeviceData
/// A regular expression that can be used to parse the device information that is returned
/// by the Android Debut Bridge.
/// </summary>
internal const string DeviceDataRegexString = @"^(?<serial>[a-zA-Z0-9_-]+(?:\s?[\.a-zA-Z0-9_-]+)?(?:\:\d{1,})?)\s+(?<state>device|offline|unknown|bootloader|recovery|download|unauthorized|host|no permissions)(\s+usb:(?<usb>[^:]+))?(?:\s+product:(?<product>[^:]+))?(\s+model\:(?<model>[\S]+))?(\s+device\:(?<device>[\S]+))?(\s+features:(?<features>[^:]+))?$";
internal const string DeviceDataRegexString = @"^(?<serial>[a-zA-Z0-9_-]+(?:\s?[\.a-zA-Z0-9_-]+)?(?:\:\d{1,})?)\s+(?<state>device|offline|unknown|bootloader|recovery|download|unauthorized|host|no permissions)(\s+usb:(?<usb>[^:]+))?(?:\s+product:(?<product>[^:]+))?(\s+model\:(?<model>[\S]+))?(\s+device\:(?<device>[\S]+))?(\s+features:(?<features>[^:]+))?(\s+transport_id:(?<transport_id>[^:]+))?$";

/// <summary>
/// A regular expression that can be used to parse the device information that is returned
Expand Down

0 comments on commit 9719f5b

Please sign in to comment.