Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
Add appium auto test for CircularShell (#242)
Browse files Browse the repository at this point in the history
* Add appium test for CircularShell (#241)

* Add Appium unit testcase

* Update Shell UI Tests (#236)

Co-authored-by: shmin <[email protected]>

* Update Icon Images (#245)

* Update WearableUIGallery to use Shell (#252)

Co-authored-by: shmin <[email protected]>
  • Loading branch information
rookiejava and shyunMin authored Mar 5, 2020
1 parent 3b17ae0 commit 680a2c9
Show file tree
Hide file tree
Showing 49 changed files with 789 additions and 69 deletions.
2 changes: 1 addition & 1 deletion sample/ShellExamples/FlyoutExample/ConfigPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Button Text="Set Default" Clicked="Button_Clicked_1"/>
<Button Text="Change Color" Clicked="Button_Clicked_2"/>
<Button Text="Change Icon BG Color" Clicked="Button_Clicked_3"/>
<Button Text="Change Foreground Color" Clicked="Button_Clicked_4"/>
<Button Text="Change Foreground Color" HeightRequest="100" Clicked="Button_Clicked_4"/>
<BoxView HeightRequest="100" Color="Transparent"/>
</StackLayout>
</ScrollView>
Expand Down
17 changes: 6 additions & 11 deletions sample/ShellExamples/FlyoutExample/RandomColorPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,23 @@ namespace FlyoutExample
public class RandomColorPage : ContentPage
{
Label Title;

public RandomColorPage()
{
Console.WriteLine("Create RandomColorPage");
var rand = new Random();
Title = new Label()
{
HorizontalOptions = LayoutOptions.CenterAndExpand,
VerticalOptions = LayoutOptions.CenterAndExpand,
};
var color = Color.FromRgb(rand.Next(255), rand.Next(255), rand.Next(255));
BackgroundColor = color;
Title = new Label();
Content = new StackLayout
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
BackgroundColor = color,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
Children =
{
new Label
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
Text = $"Color : {color.ToHex()}"
Text = $"Color : {color.ToHex()}",
},
Title,
}
Expand Down
Binary file modified sample/ShellExamples/Xaminals/Xaminals.Tizen/res/back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/ShellExamples/Xaminals/Xaminals.Tizen/res/bear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/ShellExamples/Xaminals/Xaminals.Tizen/res/cat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/ShellExamples/Xaminals/Xaminals.Tizen/res/dog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/ShellExamples/Xaminals/Xaminals.Tizen/res/elephant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/ShellExamples/Xaminals/Xaminals.Tizen/res/help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/ShellExamples/Xaminals/Xaminals.Tizen/res/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/ShellExamples/Xaminals/Xaminals.Tizen/res/monkey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/ShellExamples/Xaminals/Xaminals.Tizen/res/paw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/ShellExamples/Xaminals/Xaminals.Tizen/res/random.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions test/Appium.CircularShell.Tests/AppInitializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Appium.CircularShell.Tests
{
public class AppInitializer
{
static TizenDriverApp s_instance;
public static TizenDriverApp GetDriver()
{
if (s_instance == null)
{
//string address = "http://10.113.165.80:4723/wd/hub";
string address = "http://127.0.0.1:4723/wd/hub";
s_instance = TizenDriverApp.CreateDriver(address, "emulator-26101", "org.tizen.example.CircularShellGallery");
}
return s_instance;
}
}
}
16 changes: 16 additions & 0 deletions test/Appium.CircularShell.Tests/Appium.CircularShell.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="4.0.0.5-beta" />
<PackageReference Include="nunit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions test/Appium.CircularShell.Tests/Appium.CircularShell.Tests.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1000
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Appium.CircularShell.Tests", "Appium.CircularShell.Tests.csproj", "{C102CAD4-0841-4CB3-BB6E-BE29619B5FD4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C102CAD4-0841-4CB3-BB6E-BE29619B5FD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C102CAD4-0841-4CB3-BB6E-BE29619B5FD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C102CAD4-0841-4CB3-BB6E-BE29619B5FD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C102CAD4-0841-4CB3-BB6E-BE29619B5FD4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1E919302-4E35-4EC8-A32A-45D4BA8B9229}
EndGlobalSection
EndGlobal
42 changes: 42 additions & 0 deletions test/Appium.CircularShell.Tests/TC/TCFlyoutBackgroundColor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using NUnit.Framework;
using System.Threading;


namespace Appium.CircularShell.Tests
{
[TestFixture]
public class TCFlyoutBackgroundColor : TestCaseBase
{
public TCFlyoutBackgroundColor() : base("FlyoutBackgroundColor")
{
}

[Test]
public void SetBlueViolet()
{
FindAndClick("BlueViolet");
FindAndClick("Open");
GoBack();
FindAndClick("default");
}

[Test]
public void SetBrown()
{
FindAndClick("Brown");
FindAndClick("Open");
GoBack();
FindAndClick("default");
}

[Test]
public void SetFuchsia()
{
FindAndClick("Fuchsia");
FindAndClick("Open");
GoBack();
FindAndClick("default");
}

}
}
32 changes: 32 additions & 0 deletions test/Appium.CircularShell.Tests/TC/TCFlyoutForegroundColor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using NUnit.Framework;
using System.Threading;

namespace Appium.CircularShell.Tests
{
[TestFixture]
public class TCFlyoutForeBackgroundColor : TestCaseBase
{
public TCFlyoutForeBackgroundColor() : base("FlyoutForegroundColor") { }

[Test]
public void SetBlueViolet()
{
FindAndClick("BlueViolet");
FindAndClick("default");
}

[Test]
public void SetBrown()
{
FindAndClick("Brown");
FindAndClick("default");
}

[Test]
public void SetFuchsia()
{
FindAndClick("Fuchsia");
FindAndClick("default");
}
}
}
35 changes: 35 additions & 0 deletions test/Appium.CircularShell.Tests/TC/TCFlyoutIcon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace Appium.CircularShell.Tests
{
[TestFixture]
public class TCFlyoutIcon : TestCaseBase
{
public TCFlyoutIcon() : base("FlyoutIcon") { }

[Test]
public void SetIcon1()
{
FindAndClick("icon1");
FindAndClick("default");
}

[Test]
public void SetIcon2()
{
FindAndClick("icon2");
FindAndClick("default");
}

[Test]
public void SetIcon3()
{
FindAndClick("icon3");
FindAndClick("default");
}
}
}
32 changes: 32 additions & 0 deletions test/Appium.CircularShell.Tests/TC/TCFlyoutIconBackgroudColor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using NUnit.Framework;
using System.Threading;

namespace Appium.CircularShell.Tests
{
[TestFixture]
public class TCFlyoutIconBackgroundColor : TestCaseBase
{
public TCFlyoutIconBackgroundColor() : base("FlyoutIconBackgroundColor") { }

[Test]
public void SetBlueViolet()
{
FindAndClick("BlueViolet");
FindAndClick("default");
}

[Test]
public void SetBrown()
{
FindAndClick("Brown");
FindAndClick("default");
}

[Test]
public void SetFuchsia()
{
FindAndClick("Fuchsia");
FindAndClick("default");
}
}
}
80 changes: 80 additions & 0 deletions test/Appium.CircularShell.Tests/TestCaseBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using NUnit.Framework;

namespace Appium.CircularShell.Tests
{
public abstract class TestCaseBase
{
readonly int _screenHeight = 360;

protected TestCaseBase(string tcName)
{
TCName = tcName;
}

public string TCName { get; }

public TizenDriverApp Driver { get; set; }


[OneTimeSetUp]
public void Init()
{
Driver = AppInitializer.GetDriver();
}

[SetUp]
public void TestSetUp()
{
Driver.SetText("TCName", TCName);
FindAndClick("Go");
}

[TearDown]
public void TestCleanUp()
{
FindAndClick("Back");
}

public void GoBack()
{
Driver.Navigate().Back();
Thread.Sleep(1000);
}

public void FindAndClick(string automationId)
{
var element = Driver.FindElementByAccessibilityId(automationId);
var y = element.Location.Y;
var height = element.Size.Height;
var retry = 10;

if ((y < 0))
{
while ((y < 0) && (retry > 0))
{
Driver.Flick(0, 100);
Thread.Sleep(1000);
y = element.Location.Y;
retry--;
}
}
else if ((y + height) > _screenHeight)
{
while (((y + height) > _screenHeight) && (retry > 0))
{
Driver.Flick(0, -100);
Thread.Sleep(1000);
y = element.Location.Y;
height = element.Size.Height;
retry--;
}
}
element.Click();
Thread.Sleep(1000);
}
}
}
Loading

0 comments on commit 680a2c9

Please sign in to comment.