-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Get Performance Data & Performance Data Types #422
Merged
laolubenson
merged 8 commits into
appium:master
from
laolubenson:feature/performance-data
Sep 7, 2020
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
596e52a
feat: Get Performance Data & Performance Data Types
laolubenson 41f770d
update interface and documentation
laolubenson a4bded0
spacing
laolubenson 4a168ac
Add enum for performance data types
laolubenson 47f9ba3
spacing
laolubenson 5caf169
Add overload for GetPerformanceData
laolubenson 2c459f1
Add test for overload
laolubenson 1f2ccc1
Moved interface to andorid namespace
laolubenson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 10 additions & 0 deletions
10
src/Appium.Net/Appium/Android/Enums/PerformanceDataType.cs
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,10 @@ | ||
namespace OpenQA.Selenium.Appium.Android.Enums | ||
{ | ||
public struct PerformanceDataType | ||
{ | ||
public static string CpuInfo = "cpuinfo"; | ||
public static string MemoryInfo = "memoryinfo"; | ||
public static string BatteryInfo = "batteryinfo"; | ||
public static string NetworkInfo = "networkinfo"; | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
src/Appium.Net/Appium/Android/Interfaces/IHasPerformanceData.cs
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,85 @@ | ||
//Licensed under the Apache License, Version 2.0 (the "License"); | ||
//you may not use this file except in compliance with the License. | ||
//See the NOTICE file distributed with this work for additional | ||
//information regarding copyright ownership. | ||
//You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
//Unless required by applicable law or agreed to in writing, software | ||
//distributed under the License is distributed on an "AS IS" BASIS, | ||
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
//See the License for the specific language governing permissions and | ||
//limitations under the License. | ||
|
||
using System.Collections.Generic; | ||
using OpenQA.Selenium.Appium.Android.Enums; | ||
|
||
namespace OpenQA.Selenium.Appium.Android.Interfaces | ||
{ | ||
public interface IHasPerformanceData | ||
{ | ||
/// <summary> | ||
/// Returns the information of the system state which is supported to read e.g. cpu, memory, network | ||
/// </summary> | ||
/// <param name="packageName">The package name of the application</param> | ||
/// <param name="performanceDataType">The type of system state which you want to read, use <see cref="PerformanceDataType"/> | ||
/// or call <see cref="GetPerformanceDataTypes"/> to find a list of the supported performance data types.</param> | ||
/// <returns> | ||
/// A table like list of the performance data, The first index of the table represents the type of data. | ||
/// The remaining index represent the values of the data. | ||
/// in case of battery info : [[power], [23]] | ||
/// in case of memory info : | ||
/// [[totalPrivateDirty, nativePrivateDirty, dalvikPrivateDirty, eglPrivateDirty, glPrivateDirty, | ||
/// totalPss, nativePss, dalvikPss, eglPss, glPss, nativeHeapAllocatedSize, nativeHeapSize], | ||
/// [18360, 8296, 6132, null, null, 42588, 8406, 7024, null, null, 26519, 10344]] | ||
/// in case of network info : | ||
/// [[bucketStart, activeTime, rxBytes, rxPackets, txBytes, txPackets, operations, bucketDuration,], | ||
/// [1478091600000, null, 1099075, 610947, 928, 114362, 769, 0, 3600000], | ||
/// [1478095200000, null, 1306300, 405997, 509, 46359, 370, 0, 3600000]] | ||
/// in case of network info : | ||
/// [[st, activeTime, rb, rp, tb, tp, op, bucketDuration], | ||
/// [1478088000, null, null, 32115296, 34291, 2956805, 25705, 0, 3600], | ||
/// [1478091600, null, null, 2714683, 11821, 1420564, 12650, 0, 3600], | ||
/// [1478095200, null, null, 10079213, 19962, 2487705, 20015, 0, 3600], | ||
/// [1478098800, null, null, 4444433, 10227, 1430356, 10493, 0, 3600]] | ||
/// in case of cpu info : [[user, kernel], [0.9, 1.3]] | ||
/// </returns> | ||
IList<object> GetPerformanceData(string packageName, string performanceDataType); | ||
|
||
|
||
/// <summary> | ||
/// Returns the information of the system state which is supported to read e.g. cpu, memory, network | ||
/// </summary> | ||
/// <param name="packageName">The package name of the application</param> | ||
/// <param name="performanceDataType">The type of system state which you want to read, use <see cref="PerformanceDataType"/> | ||
/// or call <see cref="GetPerformanceDataTypes"/> to find a list of the supported performance data types.</param> | ||
/// <param name="dataReadAttempts">The number of attempts to read data in the event of a data read failure (optional). Value must be greater than 0.</param> | ||
/// <returns> | ||
/// A table like list of the performance data, The first index of the table represents the type of data. | ||
/// The remaining index represent the values of the data. | ||
/// in case of battery info : [[power], [23]] | ||
/// in case of memory info : | ||
/// [[totalPrivateDirty, nativePrivateDirty, dalvikPrivateDirty, eglPrivateDirty, glPrivateDirty, | ||
/// totalPss, nativePss, dalvikPss, eglPss, glPss, nativeHeapAllocatedSize, nativeHeapSize], | ||
/// [18360, 8296, 6132, null, null, 42588, 8406, 7024, null, null, 26519, 10344]] | ||
/// in case of network info : | ||
/// [[bucketStart, activeTime, rxBytes, rxPackets, txBytes, txPackets, operations, bucketDuration,], | ||
/// [1478091600000, null, 1099075, 610947, 928, 114362, 769, 0, 3600000], | ||
/// [1478095200000, null, 1306300, 405997, 509, 46359, 370, 0, 3600000]] | ||
/// in case of network info : | ||
/// [[st, activeTime, rb, rp, tb, tp, op, bucketDuration], | ||
/// [1478088000, null, null, 32115296, 34291, 2956805, 25705, 0, 3600], | ||
/// [1478091600, null, null, 2714683, 11821, 1420564, 12650, 0, 3600], | ||
/// [1478095200, null, null, 10079213, 19962, 2487705, 20015, 0, 3600], | ||
/// [1478098800, null, null, 4444433, 10227, 1430356, 10493, 0, 3600]] | ||
/// in case of cpu info : [[user, kernel], [0.9, 1.3]] | ||
/// </returns> | ||
IList<object> GetPerformanceData(string packageName, string performanceDataType, int dataReadAttempts); | ||
|
||
/// <summary> | ||
/// Returns the information types of the system state which is supported to read as like cpu, memory, network traffic, and battery | ||
/// </summary> | ||
IList<string> GetPerformanceDataTypes(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using Appium.Net.Integration.Tests.helpers; | ||
using NUnit.Framework; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Appium; | ||
using OpenQA.Selenium.Appium.Android; | ||
using OpenQA.Selenium.Appium.Android.Enums; | ||
|
||
namespace Appium.Net.Integration.Tests.Android.Device | ||
{ | ||
internal class PerformanceDataTests | ||
{ | ||
private AppiumDriver<IWebElement> _driver; | ||
private AppiumOptions _androidOptions; | ||
|
||
|
||
[OneTimeSetUp] | ||
public void SetUp() | ||
{ | ||
_androidOptions = Caps.GetAndroidUIAutomatorCaps(Apps.Get(Apps.androidApiDemos)); | ||
_driver = new AndroidDriver<IWebElement>( | ||
Env.ServerIsLocal() ? AppiumServers.LocalServiceUri : AppiumServers.RemoteServerUri, | ||
_androidOptions); | ||
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); | ||
} | ||
|
||
[OneTimeTearDown] | ||
public void TearDown() | ||
{ | ||
_driver.Dispose(); | ||
} | ||
|
||
[Test] | ||
public void GetPerformanceDataTypesTest() | ||
{ | ||
var androidDriver = _driver as AndroidDriver<IWebElement>; | ||
Assert.IsNotNull(androidDriver.GetPerformanceDataTypes()); | ||
} | ||
|
||
[Test] | ||
public void GetPerformanceDataTest() | ||
{ | ||
var androidDriver = _driver as AndroidDriver<IWebElement>; | ||
var packageName = androidDriver?.CurrentPackage; | ||
|
||
Assert.Multiple(() => | ||
{ | ||
Assert.That(androidDriver?.GetPerformanceData(packageName, PerformanceDataType.CpuInfo), Is.Not.Null.Or.Empty); | ||
Assert.That(androidDriver?.GetPerformanceData(packageName, PerformanceDataType.CpuInfo, 15), | ||
Is.Not.Null.Or.Empty); | ||
Assert.That(androidDriver?.GetPerformanceData(packageName, PerformanceDataType.MemoryInfo, 5), | ||
Is.Not.Null.Or.Empty); | ||
Assert.That(androidDriver?.GetPerformanceData(packageName, PerformanceDataType.BatteryInfo, 5), | ||
Is.Not.Null.Or.Empty); | ||
Assert.That(androidDriver?.GetPerformanceData(packageName, PerformanceDataType.NetworkInfo, 5), | ||
Is.Not.Null.Or.Empty); | ||
}); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍