File: Tests.cs

package info (click to toggle)
onnxruntime 1.21.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 333,732 kB
  • sloc: cpp: 3,153,079; python: 179,219; ansic: 109,131; asm: 37,791; cs: 34,424; perl: 13,070; java: 11,047; javascript: 6,330; pascal: 4,126; sh: 3,277; xml: 598; objc: 281; makefile: 59
file content (49 lines) | stat: -rw-r--r-- 1,884 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Threading;
using Microsoft.ML.OnnxRuntime.Tests.Devices;
using Newtonsoft.Json;
using NUnit.Framework;
using Xamarin.UITest;

namespace EndToEndTests.Mobile.Automation
{
    [TestFixture(Platform.Android)]
    [TestFixture(Platform.iOS)]
    public class Tests
    {
        IApp _app;
        Platform _platform;
        string _getResultsBackdoorMethodName;
        string _activityIndicatorClassName;

        public Tests(Platform platform)
        {
            _platform = platform;
            _activityIndicatorClassName = platform == Platform.Android ? "ActivityIndicatorRenderer" : "Xamarin_Forms_Platform_iOS_ActivityIndicatorRenderer";
            _getResultsBackdoorMethodName = platform == Platform.Android ? "GetTestResults" : "getTestResults";
        }

        [SetUp]
        public void BeforeEachTest()
            => _app = AppInitializer.StartApp(_platform);

        [Test]
        public void RunPlatformUnitTest()
        {
            _app.Screenshot("Pre-testing");
            _app.WaitForElement(i => i.Marked("Run Everything"));
            _app.Tap(i => i.Marked("Run Everything"));
            _app.WaitForElement(i => i.Class(_activityIndicatorClassName));
            _app.WaitForNoElement(i => i.Class(_activityIndicatorClassName).Child(0), timeout: TimeSpan.FromSeconds(30));
            Thread.Sleep(1000); // Gives the test app sufficient time to prepare the results

            var serializedResultSummary = _app.Invoke(_getResultsBackdoorMethodName)?.ToString();
            Assert.IsNotEmpty(serializedResultSummary, "Test results were not returned");

            var testSummary = JsonConvert.DeserializeObject<TestResultSummary>(serializedResultSummary);
            Assert.AreEqual(testSummary.Failed, 0, $"{testSummary.Failed} tests failed");

            _app.Screenshot("Post-testing");
        }
    }
}