Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Tizen.Appium.Forms/FormsAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
using Xamarin.Forms.Platform.Tizen;
using Tizen.Appium.Forms;

#if WATCH
using CShellItemContext = Tizen.Wearable.CircularUI.Forms.Renderer.NavigationView.ItemContext;
#endif

namespace Tizen.Appium
{
public class FormsAdapter : BaseAdapter
Expand Down Expand Up @@ -43,9 +47,34 @@ protected override void AdaptApp()
{
AddItemFromList(e.View);
}
#if WATCH
if (e.View is Shell shell)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to assume only when this is a watch?

{
AddShellItems(shell);
}
#endif
};
}

#if WATCH
void AddShellItems(Shell shell)
{
var naviView = (Platform.GetOrCreateRenderer(shell) as Wearable.CircularUI.Forms.Renderer.ShellRenderer)?.NavigationView;
if (naviView != null)
{
naviView.ItemRealized += (s, e) =>
{
ObjectList.Add(e.Item.Data);
};

naviView.ItemUnrealized += (s, e) =>
{
var id = (e.Item.Data as CShellItemContext)?.Source.GetId();
ObjectList.RemoveById(id);
};
}
}
#endif
void AddItemFromList(VisualElement list)
{
var nativeView = (ElmSharp.GenList)Platform.GetOrCreateRenderer(list).NativeView;
Expand Down
11 changes: 10 additions & 1 deletion Tizen.Appium.Forms/FormsElementList.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using Xamarin.Forms;
using ItemContext = Xamarin.Forms.Platform.Tizen.Native.ListView.ItemContext;

#if WATCH
using ShellItemContext = Tizen.Wearable.CircularUI.Forms.Renderer.NavigationView.ItemContext;
#endif

namespace Tizen.Appium.Forms
{
public class FormsElementList : BaseObjectList
Expand All @@ -15,7 +19,12 @@ protected override IObjectWrapper CreateWrapper(object obj)
{
return new CellWrapper(ic);
}

#if WATCH
else if (obj is ShellItemContext sic)
{
return new ShellItemWrapper(sic);
}
#endif
return null;
}
}
Expand Down
86 changes: 86 additions & 0 deletions Tizen.Appium.Forms/ShellItemWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System;
using Xamarin.Forms;
using CShellItemContext = Tizen.Wearable.CircularUI.Forms.Renderer.NavigationView.ItemContext;

namespace Tizen.Appium.Forms
{
public class ShellItemWrapper : BaseObjectWrapper<Element>
{
WeakReference<CShellItemContext> _ref;
string _id;

public override string[] TextProperties => new string[] { "Title", "Text", "FormattedText" };
public override string[] DisplayedTextProperies => new string[] { "Text", "Name", "FormattedText", "Title", "Detail" };

public override event EventHandler Deleted;

public override string Id => _id;

public override bool IsShown
{
get
{
return (Control != null) ? Control.GetIsShownProperty() : false;
}
}

public override Element Control
{
get
{
return Context?.Source;
}
}

public override Geometry Geometry
{
get
{
return TizenAppium.RunOnMainThread<Geometry>(() =>
{
if (Control != null)
{
var trackObj = Context.Item.TrackObject;
if (trackObj != null)
{
return new Geometry(trackObj.Geometry.X, trackObj.Geometry.Y, trackObj.Geometry.Width, trackObj.Geometry.Height);
}
}

return new Geometry();
});
}
}

public override bool IsFocused
{
get
{
return (Control != null) ? Context.Item.IsSelected : false;
}
}

CShellItemContext Context
{
get
{
CShellItemContext ic;
if(_ref.TryGetTarget(out ic))
{
return ic;
}

Deleted?.Invoke(this, EventArgs.Empty);
return null;
}
}

public ShellItemWrapper(CShellItemContext ic)
{
_ref = new WeakReference<CShellItemContext>(ic);
_id = ic.Source.GetId();

ic.Item.Deleted += (s, e) => Deleted?.Invoke(this, EventArgs.Empty);
}
}
}
10 changes: 9 additions & 1 deletion Tizen.Appium.Forms/Tizen.Appium.Forms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;WATCH</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand All @@ -25,6 +25,14 @@
<PackageReference Include="Xamarin.Forms" Version="4.4.0.991537" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Tizen.CircularUI-shyun\src\Tizen.Wearable.CircularUI.Forms.Renderer\Tizen.Wearable.CircularUI.Forms.Renderer.csproj" Condition="$(DefineConstants.Contains('WATCH'))"/>
</ItemGroup>

<ItemGroup Condition="!$(DefineConstants.Contains('WATCH'))">
<Compile Remove="ShellItemWrapper.cs" />
</ItemGroup>

<Import Project="..\Tizen.Appium.Shared\Tizen.Appium.projitems" Label="Shared" />

</Project>
15 changes: 2 additions & 13 deletions Tizen.Appium.Shared/AppAdapter/BaseObjectList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,13 @@ public void Add(object element)
else
{
_list.TryUpdate(wrapper.Id, wrapper, _list[wrapper.Id]);
Log.Debug("[Updated] " + wrapper.Id + " object already exists. It wiill be upsted to element=" + element.GetType() + ", _elements.Count=" + _list.Count);
Log.Debug("[Updated] " + wrapper.Id + " object already exists. It wiill be updated to element=" + element.GetType() + ", _elements.Count=" + _list.Count);
}
}

public void Remove(object element)
{
var key = _list.Where(kv => kv.Value.EqualsTo(element)).FirstOrDefault().Key;
RemoveById(key);
}

public void RemoveById(string id)
{
if (_list.ContainsKey(id))
if (!string.IsNullOrEmpty(id) && _list.ContainsKey(id))
{
IObjectWrapper wrapper;
_list.TryRemove(id, out wrapper);
Expand Down Expand Up @@ -78,11 +72,6 @@ public IObjectWrapper Get(string id)
return null;
}

public string GetIdByObject(object element)
{
return _list.FirstOrDefault(kv => kv.Value.EqualsTo(element)).Key;
}

public IEnumerable<string> GetIdsByName(string name)
{
var selected = _list.Where(kv => kv.Value.IsShown && kv.Value.ContainsText(name)).Select(kv => kv.Value.Id);
Expand Down
2 changes: 0 additions & 2 deletions Tizen.Appium.Shared/AppAdapter/IObjectList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ public interface IObjectList
{
void Add(object element);

void Remove(object element);

void RemoveById(string id);

IObjectWrapper Get(string id);
Expand Down
2 changes: 1 addition & 1 deletion Tizen.Appium.Shared/InputGenerator/InputGenerator.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public bool TouchMove(int xDown, int yDown, int xUp, int yUp, int steps)
public bool Drag(int xDown, int yDown, int xUp, int yUp)
{
#if WATCH
steps = 100;
_steps = 100;
#endif
var data = new Bundle();

Expand Down