From 3c34516e4554c94e66812a91ca8b24959fe40658 Mon Sep 17 00:00:00 2001 From: Jeongkyun Date: Mon, 31 Jul 2017 11:57:12 +0900 Subject: [PATCH] add test case for wearable profile add Image Test 1,2,3,4 add Index Test 1.2 add List Test add Progressbar Test 1.2 add Radio Test add Rectangle Test add ScreenInformation Test add Scroller Test 1,2,3 add Slider Test 1,2 add Spinner Test add TransitTest add WindowInternalTest Change-Id: Ida883bc0c8be3406f9cdc97ead33ea20f6af6665 Signed-off-by: Jeongkyun --- test/ElmSharp.Test/ElmSharp.Test.csproj | 20 +++ test/ElmSharp.Test/TC/Wearable/ImageTest1.cs | 147 ++++++++++++++++++ test/ElmSharp.Test/TC/Wearable/ImageTest2.cs | 84 +++++++++++ test/ElmSharp.Test/TC/Wearable/ImageTest3.cs | 96 ++++++++++++ test/ElmSharp.Test/TC/Wearable/ImageTest4.cs | 77 ++++++++++ test/ElmSharp.Test/TC/Wearable/IndexTest1.cs | 115 ++++++++++++++ test/ElmSharp.Test/TC/Wearable/IndexTest2.cs | 153 +++++++++++++++++++ test/ElmSharp.Test/TC/Wearable/ListTest1.cs | 134 +++++++++++++++++ test/ElmSharp.Test/TC/Wearable/ProgressBarTest1.cs | 158 ++++++++++++++++++++ test/ElmSharp.Test/TC/Wearable/ProgressBarTest2.cs | 80 ++++++++++ test/ElmSharp.Test/TC/Wearable/RadioTest1.cs | 99 ++++++++++++ test/ElmSharp.Test/TC/Wearable/RectangleTest1.cs | 46 ++++++ .../TC/Wearable/ScreenInformationTest.cs | 45 ++++++ test/ElmSharp.Test/TC/Wearable/ScrollerTest1.cs | 79 ++++++++++ test/ElmSharp.Test/TC/Wearable/ScrollerTest2.cs | 134 +++++++++++++++++ test/ElmSharp.Test/TC/Wearable/ScrollerTest3.cs | 130 ++++++++++++++++ test/ElmSharp.Test/TC/Wearable/SliderTest1.cs | 166 +++++++++++++++++++++ test/ElmSharp.Test/TC/Wearable/SliderTest2.cs | 147 ++++++++++++++++++ test/ElmSharp.Test/TC/Wearable/SpinnerTest1.cs | 67 +++++++++ test/ElmSharp.Test/TC/Wearable/TransitTest.cs | 90 +++++++++++ .../TC/Wearable/WindowInternalTest.cs | 97 ++++++++++++ 21 files changed, 2164 insertions(+) mode change 100644 => 100755 test/ElmSharp.Test/ElmSharp.Test.csproj create mode 100755 test/ElmSharp.Test/TC/Wearable/ImageTest1.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/ImageTest2.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/ImageTest3.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/ImageTest4.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/IndexTest1.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/IndexTest2.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/ListTest1.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/ProgressBarTest1.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/ProgressBarTest2.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/RadioTest1.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/RectangleTest1.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/ScreenInformationTest.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/ScrollerTest1.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/ScrollerTest2.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/ScrollerTest3.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/SliderTest1.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/SliderTest2.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/SpinnerTest1.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/TransitTest.cs create mode 100755 test/ElmSharp.Test/TC/Wearable/WindowInternalTest.cs diff --git a/test/ElmSharp.Test/ElmSharp.Test.csproj b/test/ElmSharp.Test/ElmSharp.Test.csproj old mode 100644 new mode 100755 index f50c7fb..d8b242d --- a/test/ElmSharp.Test/ElmSharp.Test.csproj +++ b/test/ElmSharp.Test/ElmSharp.Test.csproj @@ -159,6 +159,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/test/ElmSharp.Test/TC/Wearable/ImageTest1.cs b/test/ElmSharp.Test/TC/Wearable/ImageTest1.cs new file mode 100755 index 0000000..b7c7c5a --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/ImageTest1.cs @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; +using System.IO; + +namespace ElmSharp.Test.Wearable +{ + public class ImageTest1 : WearableTestCase + { + public override string TestName => "ImageTest1"; + public override string TestDescription => "To test basic operation of Image"; + + Image image; + Label lbInfo; + string[] btn_names = new string[] {"File1", "File2", "Uri", "Strm", "FileA1", "FileA2", "UriA", "StrmA"}; + + public override void Run(Window window) + { + Rect square = window.GetInnerSquare(); + + Button[] btns = new Button[8]; + Size btnSize = new Size(square.Width / 4 - 2, square.Height / 5 - 1); + for (int i = 0; i < 2; i++) + { + for (int j = 0; j < 4; j++) + { + btns[i * 4 + j] = new Button(window) + { + Text = "" + btn_names[i * 4 + j] + "", + }; + int x = j * btnSize.Width + j *2; + int y = i * btnSize.Height + i; + btns[i * 4 + j].Geometry = new Rect(square.X + x, square.Y + y, btnSize.Width, btnSize.Height); + btns[i * 4 + j].Show(); + } + } + + lbInfo = new Label(window) + { + Color = Color.White, + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1 + }; + lbInfo.Show(); + lbInfo.Geometry = new Rect(square.X, square.Y + square.Height, square.Width, 15); + + image = new Image(window) + { + IsFixedAspect = true, + AlignmentX = -1, + AlignmentY = -1, + }; + image.Show(); + image.Load(Path.Combine(TestRunner.ResourceDir, "picture.png")); + image.Geometry = new Rect(square.X, square.Y + btnSize.Height * 2 + 2 , square.Width, btnSize.Height * 3); + image.Clicked += (s, e) => + { + Console.WriteLine("Image has been clicked. (IsFixedAspect = {0}", image.IsFixedAspect); + image.IsFixedAspect = image.IsFixedAspect == true ? false : true; + }; + + btns[0].Clicked += (s, e) => LoadFile("TED/large/a.jpg"); + btns[1].Clicked += (s, e) => LoadFile("TED/large/b.jpg"); + btns[2].Clicked += (s, e) => LoadUri("http://pe.tedcdn.com/images/ted/2e306b9655267cee35e45688ace775590b820510_615x461.jpg"); + btns[3].Clicked += (s, e) => LoadStream(new FileStream(Path.Combine(TestRunner.ResourceDir, "TED/large/c.jpg"), FileMode.Open)); + + btns[4].Clicked += (s, e) => LoadFileAsync("TED/large/d.jpg"); + btns[5].Clicked += (s, e) => LoadFileAsync("TED/large/e.jpg"); + btns[6].Clicked += (s, e) => LoadUriAsync("http://pe.tedcdn.com/images/ted/2e306b9655267cee35e45688ace775590b820510_615x461.jpg"); + btns[7].Clicked += (s, e) => LoadStreamAsync(new FileStream(Path.Combine(TestRunner.ResourceDir, "TED/large/f.jpg"), FileMode.Open)); + } + + void LoadFile(string file) + { + bool ret = image.Load(Path.Combine(TestRunner.ResourceDir, file)); + if (ret) + UpdateLabelText(lbInfo, image.File); + else + UpdateLabelText(lbInfo, "Loading Failed."); + } + + void LoadUri(string uri) + { + bool ret = image.Load(uri); + if (ret) + UpdateLabelText(lbInfo, image.File); + else + UpdateLabelText(lbInfo, "Loading Failed."); + } + + void LoadStream(Stream stream) + { + bool ret = image.Load(stream); + if (ret) + UpdateLabelText(lbInfo, image.File); + else + UpdateLabelText(lbInfo, "Loading Failed."); + } + + async void LoadFileAsync(string file) + { + var ret = await image.LoadAsync(Path.Combine(TestRunner.ResourceDir, file)); + if (ret) + UpdateLabelText(lbInfo, image.File); + else + UpdateLabelText(lbInfo, "Loading Failed."); + } + + async void LoadUriAsync(string uri) + { + var ret = await image.LoadAsync(uri); + if (ret) + UpdateLabelText(lbInfo, image.File); + else + UpdateLabelText(lbInfo, "Loading Failed."); + } + + async void LoadStreamAsync(Stream stream) + { + var ret = await image.LoadAsync(stream); + if (ret) + UpdateLabelText(lbInfo, image.File); + else + UpdateLabelText(lbInfo, "Loading Failed."); + } + + void UpdateLabelText(Label lable, string text) + { + lable.Text = "" + text + ""; + } + } +} diff --git a/test/ElmSharp.Test/TC/Wearable/ImageTest2.cs b/test/ElmSharp.Test/TC/Wearable/ImageTest2.cs new file mode 100755 index 0000000..4842c01 --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/ImageTest2.cs @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; +using System.IO; + +namespace ElmSharp.Test.Wearable +{ + public class ImageTest2 : WearableTestCase + { + public override string TestName => "ImageTest2"; + public override string TestDescription => "To test basic operation of Image"; + + Image image; + Label lbInfo; + + string[] btn_names = new string[] { "Blue", "Default", "Aspect", "Rotate" }; + + public override void Run(Window window) + { + Rect square = window.GetInnerSquare(); + + Button[] btns = new Button[4]; + Size btnSize = new Size(square.Width / 4 - 2, square.Height / 4); + for (int i = 0; i < 4; i++) + { + btns[i] = new Button(window) + { + Text = "" + btn_names[i] + "", + }; + int x = i * btnSize.Width + i * 2; + btns[i].Geometry = new Rect(square.X + x, square.Y, btnSize.Width, btnSize.Height); + btns[i].Show(); + } + + lbInfo = new Label(window) { + Color = Color.White, + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1 + }; + lbInfo.Show(); + lbInfo.Geometry = new Rect(square.X, square.Y + square.Height, square.Width, 15); + + image = new Image(window) { + IsFixedAspect = true, + AlignmentX = -1, + AlignmentY = -1, + }; + image.Show(); + image.Load(Path.Combine(TestRunner.ResourceDir, "picture.png")); + image.Geometry = new Rect(square.X, square.Y + btnSize.Height, square.Width, btnSize.Height * 3); + + image.Clicked += (s, e) => + { + Console.WriteLine("Image has been clicked. (IsFixedAspect = {0}", image.IsFixedAspect); + image.IsFixedAspect = image.IsFixedAspect == true ? false : true; + }; + + btns[0].Clicked += (s, e) => { image.BackgroundColor = Color.Blue; UpdateLabelText(image.BackgroundColor.ToString()); }; + btns[1].Clicked += (s, e) => { image.BackgroundColor = Color.Default; UpdateLabelText(image.BackgroundColor.ToString()); }; + btns[2].Clicked += (s, e) => { image.IsFixedAspect = image.IsFixedAspect == true ? false : true; }; + btns[3].Clicked += (s, e) => { image.Orientation = image.Orientation == ImageOrientation.None ? ImageOrientation.Rotate270 : ImageOrientation.None; }; + } + + void UpdateLabelText(string text) + { + lbInfo.Text = " BackgroundColor => " + text + ""; + } + } +} diff --git a/test/ElmSharp.Test/TC/Wearable/ImageTest3.cs b/test/ElmSharp.Test/TC/Wearable/ImageTest3.cs new file mode 100755 index 0000000..fa96a6e --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/ImageTest3.cs @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; +using System.IO; + +namespace ElmSharp.Test.Wearable +{ + public class ImageTest3 : WearableTestCase + { + public override string TestName => "ImageTest3"; + public override string TestDescription => "To test basic operation of Image"; + + Image image; + Label lbInfo; + + string[] btn_names = new string[] { "Blue(BG)", "Default(BG)", "Blue(FG)", "Default(FG)" }; + + public override void Run(Window window) + { + + Rect square = window.GetInnerSquare(); + + Button[] btns = new Button[4]; + Size btnSize = new Size(square.Width / 2 , square.Height / 5); + for (int i = 0; i < 2; i++) + { + for (int j = 0; j < 2; j++) + { + btns[i * 2 + j] = new Button(window) + { + Text = "" + btn_names[i * 2 + j] + "", + + }; + int x = j * btnSize.Width + j * 2; + int y = i * btnSize.Height + i; + btns[i * 2 + j].Geometry = new Rect(square.X + x, square.Y + y, btnSize.Width, btnSize.Height); + btns[i * 2 + j].Show(); + } + } + + lbInfo = new Label(window) { + Color = Color.White, + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1 + }; + lbInfo.Show(); + lbInfo.Geometry = new Rect(square.X, square.Y + square.Height, square.Width, 15); + + image = new Image(window) { + IsFixedAspect = true, + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + image.Show(); + image.Load(Path.Combine(TestRunner.ResourceDir, "btn_delete.png")); + image.Geometry = new Rect(square.X, square.Y + btnSize.Height * 2 + 2, square.Width, btnSize.Height * 3 ); + + image.Clicked += (s, e) => + { + Console.WriteLine("Image has been clicked. (IsFixedAspect = {0}", image.IsFixedAspect); + image.IsFixedAspect = image.IsFixedAspect == true ? false : true; + }; + + btns[0].Clicked += (s, e) => { image.BackgroundColor = Color.Blue; UpdateLabelText(image.BackgroundColor.ToString()); }; + btns[1].Clicked += (s, e) => { image.BackgroundColor = Color.Default; UpdateLabelText(image.BackgroundColor.ToString()); }; + btns[2].Clicked += (s, e) => { image.Color = Color.Blue; UpdateLabelText(image.Color.ToString(), false); }; + btns[3].Clicked += (s, e) => { image.Color = Color.Default; UpdateLabelText(image.Color.ToString(), false); }; + + } + + void UpdateLabelText(string text, bool isBackground = true) + { + if(isBackground) + lbInfo.Text = " Background Color => " + text + ""; + else + lbInfo.Text = " Foreground Color => " + text + ""; + } + } +} diff --git a/test/ElmSharp.Test/TC/Wearable/ImageTest4.cs b/test/ElmSharp.Test/TC/Wearable/ImageTest4.cs new file mode 100755 index 0000000..f44a391 --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/ImageTest4.cs @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; +using System.IO; + +namespace ElmSharp.Test.Wearable +{ + public class ImageTest4 : WearableTestCase + { + public override string TestName => "ImageTest4"; + public override string TestDescription => "To test border operation of Image"; + + Image image; + + public override void Run(Window window) + { + Rect square = window.GetInnerSquare(); + Log.Debug(square.ToString()); + + Button btnBorder = new Button(window) + { + Text = "Set : off", + }; + btnBorder.Resize(square.Width / 2, square.Height / 4); + btnBorder.Move(square.X, square.Y); + btnBorder.Show(); + + Button btnBorderCenterFillMode = new Button(window) + { + Text = "FillMode", + }; + btnBorderCenterFillMode.Resize(square.Width / 2, square.Height / 4); + btnBorderCenterFillMode.Move(square.X + square.Width / 2 , square.Y); + btnBorderCenterFillMode.Show(); + + image = new Image(window); + image.Load(Path.Combine(TestRunner.ResourceDir, "picture.png")); + image.MinimumWidth = square.Width; + image.MinimumHeight = square.Height * 3 / 4; + image.Move(square.X, square.Y + square.Height / 4); + image.Resize(square.Width, square.Height * 3 / 4); + image.Show(); + + + btnBorder.Clicked += (s, e) => + { + int nX = square.Width / 6; + int nY = square.Height / 8; + Log.Debug("image.Width" + image.ObjectSize.Width.ToString()); + Log.Debug("image.Height" + image.ObjectSize.Height.ToString()); + Log.Debug("nX :" + nX + ", nY :" + nY); + image.SetBorder(nX, nX, nY, nY); + btnBorder.Text = "Border Set : on"; + }; + + btnBorderCenterFillMode.Clicked += (s, e) => + { + image.BorderCenterFillMode = ((ImageBorderFillMode)Enum.ToObject(typeof(ImageBorderFillMode), ((int)image.BorderCenterFillMode + 1) % Enum.GetValues(typeof(ImageBorderFillMode)).Length)); + btnBorderCenterFillMode.Text = image.BorderCenterFillMode.ToString(); + }; + } + } +} \ No newline at end of file diff --git a/test/ElmSharp.Test/TC/Wearable/IndexTest1.cs b/test/ElmSharp.Test/TC/Wearable/IndexTest1.cs new file mode 100755 index 0000000..4199fcc --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/IndexTest1.cs @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; +using System.Collections.Generic; + +namespace ElmSharp.Test.Wearable +{ + class IndexTest1 : WearableTestCase + { + Dictionary _indexTable = new Dictionary(); + public override string TestName => "IndexTest1"; + public override string TestDescription => "To test group operation of Index"; + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Box box = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + IsHorizontal = true, + }; + box.Show(); + GenList list = new GenList(window) + { + Homogeneous = false, + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + list.Show(); + Index index = new Index(window) + { + IsHorizontal = false, + AlignmentY = -1, + WeightY = 1, + MinimumWidth = 100, + AutoHide = false, + Style = "fastscroll" + }; + index.Show(); + + GenItemClass groupClass = new GenItemClass("group_index") + { + GetTextHandler = (obj, part) => + { + return string.Format("{0} - {1}", (string)obj, part); + } + }; + + GenListItem[] groups = new GenListItem[10]; + + for (int i = 0; i < 10; i++) + { + groups[i] = list.Append(groupClass, string.Format("{0}", i), GenListItemType.Group); + var indexitem = index.Append(string.Format("{0}", i)); + indexitem.Selected += (s, e) => + { + Console.WriteLine("Index selected : {0}", ((IndexItem)s).Text); + list.ScrollTo(_indexTable[(IndexItem)s], ScrollToPosition.In, true); + }; + _indexTable[indexitem] = groups[i]; + } + + GenItemClass defaultClass = new GenItemClass("default") + { + GetTextHandler = (obj, part) => + { + return string.Format("{0} - {1}", (string)obj, part); + } + }; + + for (int j = 0; j < 10; j++) + { + for (int i = 0; i < 20; i++) + { + list.Append(defaultClass, string.Format("{0} Item", i), GenListItemType.Normal, groups[j]); + } + } + + list.ItemSelected += List_ItemSelected; + index.Update(0); + box.PackEnd(list); + box.PackEnd(index); + box.SetLayoutCallback(() => + { + list.Geometry = box.Geometry; + index.Geometry = box.Geometry; + }); + conformant.SetContent(box); + } + + private void List_ItemSelected(object sender, GenListItemEventArgs e) + { + Console.WriteLine("{0} Item was selected", (string)(e.Item.Data)); + } + } +} diff --git a/test/ElmSharp.Test/TC/Wearable/IndexTest2.cs b/test/ElmSharp.Test/TC/Wearable/IndexTest2.cs new file mode 100755 index 0000000..e6fcbb2 --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/IndexTest2.cs @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; +using System.Collections.Generic; + +namespace ElmSharp.Test.Wearable +{ + public class IndexTest2 : WearableTestCase + { + Dictionary _indexTable = new Dictionary(); + + public override string TestName => "IndexTest2"; + public override string TestDescription => "To test basic operation of Index"; + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Box outterBox = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + IsHorizontal = false, + }; + outterBox.Show(); + Scroller scroller = new Scroller(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + ScrollBlock = ScrollBlock.Vertical, + HorizontalPageScrollLimit = 1, + }; + scroller.SetPageSize(1.0, 1.0); + scroller.Show(); + + Box box = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + IsHorizontal = true, + }; + box.Show(); + scroller.SetContent(box); + + Index index = new Index(window) + { + IsHorizontal = true, + Style = "pagecontrol", + AlignmentX = -1, + WeightX = 1, + MinimumHeight = 100, + }; + index.Show(); + + var rnd = new Random(); + for (int i = 0; i < 10; i++) + { + int r = rnd.Next(255); + int g = rnd.Next(255); + int b = rnd.Next(255); + Color color = Color.FromRgb(r, g, b); + Rectangle colorBox = new Rectangle(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + Color = color, + MinimumWidth = window.ScreenSize.Width, + }; + colorBox.Show(); + Console.WriteLine("Height = {0}", colorBox.Geometry.Height); + box.PackEnd(colorBox); + var item = index.Append(string.Format("{0}", i)); + item.Selected += (s, e) => + { + scroller.ScrollTo(_indexTable[(IndexItem)s], 0, true); + }; + _indexTable[item] = i; + } + + conformant.SetContent(outterBox); + outterBox.PackEnd(scroller); + + Box buttonBox = new Box(window) + { + IsHorizontal = true, + AlignmentX = -1, + AlignmentY = 0, + }; + buttonBox.Show(); + + Button prev = new Button(window) + { + AlignmentX = -1, + WeightX = 1, + Text = "Prev" + }; + Button next = new Button(window) + { + AlignmentX = -1, + WeightX = 1, + Text = "next" + }; + prev.Clicked += (s, e) => + { + scroller.ScrollTo(scroller.HorizontalPageIndex > 0 ? scroller.HorizontalPageIndex - 1 : 0, scroller.VerticalPageIndex, true); + }; + next.Clicked += (s, e) => + { + scroller.ScrollTo(scroller.HorizontalPageIndex + 1, scroller.VerticalPageIndex, true); + }; + prev.Show(); + next.Show(); + buttonBox.PackEnd(prev); + buttonBox.PackEnd(next); + outterBox.PackEnd(buttonBox); + outterBox.PackEnd(index); + + scroller.DragStart += Scroller_DragStart; + scroller.DragStop += Scroller_DragStop; + } + + private void Scroller_DragStop(object sender, EventArgs e) + { + Log.Debug("Drag stop"); + } + + private void Scroller_DragStart(object sender, EventArgs e) + { + Log.Debug("Drag start"); + } + } +} diff --git a/test/ElmSharp.Test/TC/Wearable/ListTest1.cs b/test/ElmSharp.Test/TC/Wearable/ListTest1.cs new file mode 100755 index 0000000..fbcc536 --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/ListTest1.cs @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; + +namespace ElmSharp.Test.Wearable +{ + public class ListTest1 : WearableTestCase + { + public override string TestName => "ListTest1"; + public override string TestDescription => "To test basic operation of List"; + private int _count = 0; + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Box box = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + }; + box.Show(); + conformant.SetContent(box); + + List list = new List(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + + _count = 0; + + for (int i = 0; i < 5; i++) + { + list.Append(string.Format("{0} item", _count++)); + } + + list.ItemSelected += List_Selected; + list.ItemUnselected += List_Unselected; + list.ItemActivated += List_ItemActivated; + list.ItemDoubleClicked += List_ItemDoubleClicked; + list.ItemLongPressed += List_ItemLongPressed; + list.RenderPost += List_RenderPost; + list.Update(); + list.Show(); + + box.PackEnd(list); + + Box buttonBox = new Box(window) + { + IsHorizontal = true, + AlignmentX = -1, + AlignmentY = 0, + }; + buttonBox.Show(); + + Button append = new Button(window) + { + Text = "Append", + AlignmentX = -1, + WeightX = 1, + }; + Button prepend = new Button(window) + { + Text = "Prepend", + AlignmentX = -1, + WeightX = 1, + }; + append.Clicked += (s, e) => + { + list.Append(string.Format("{0} item", _count++)); + list.Update(); + }; + prepend.Clicked += (s, e) => + { + list.Prepend(string.Format("{0} item", _count++)); + list.Update(); + }; + append.Show(); + prepend.Show(); + buttonBox.PackEnd(append); + buttonBox.PackEnd(prepend); + box.PackEnd(buttonBox); + } + + int count = 0; + private void List_RenderPost(object sender, EventArgs e) + { + Console.WriteLine("{0} List_RenderPost", count++); + } + + private void List_ItemLongPressed(object sender, ListItemEventArgs e) + { + Console.WriteLine("{0} item was long pressed", e.Item.Text); + } + + private void List_ItemDoubleClicked(object sender, ListItemEventArgs e) + { + Console.WriteLine("{0} item was Double clicked", e.Item.Text); + } + + private void List_ItemActivated(object sender, ListItemEventArgs e) + { + Console.WriteLine("{0} item was Activated", e.Item.Text); + } + + private void List_Unselected(object sender, ListItemEventArgs e) + { + Console.WriteLine("{0} item was unselected", e.Item.Text); + } + + private void List_Selected(object sender, ListItemEventArgs e) + { + Console.WriteLine("{0} item was selected", e.Item.Text); + } + } +} diff --git a/test/ElmSharp.Test/TC/Wearable/ProgressBarTest1.cs b/test/ElmSharp.Test/TC/Wearable/ProgressBarTest1.cs new file mode 100755 index 0000000..1a4184e --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/ProgressBarTest1.cs @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ + +namespace ElmSharp.Test.Wearable +{ + class ProgressBarTest1 : WearableTestCase + { + public override string TestName => "ProgressBarTest1"; + public override string TestDescription => "To test basic operation of ProgressBar"; + + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Table table = new Table(window); + conformant.SetContent(table); + table.Show(); + + ProgressBar pb1 = new ProgressBar(window) + { + Text = "ProgressBar Test", + UnitFormat = "%.0f %%", + Value = 0.1, + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1 + }; + + Label lb1 = new Label(window) + { + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1 + }; + + Label lb2 = new Label(window) + { + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1 + }; + + Button bt1 = new Button(window) + { + Text = "Increase Value", + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1 + }; + + Button bt2 = new Button(window) + { + Text = "Decrease Value", + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1 + }; + + Button bt3 = new Button(window) + { + Text = "Increase PartValue", + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1 + }; + + Button bt4 = new Button(window) + { + Text = "Decrease PartValue", + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1 + }; + + string part = "elm.cur.progressbar"; + double unit = 0.1; + double max = 1.0; + double min = 0; + + pb1.ValueChanged += (s, e) => + { + lb1.Text = string.Format("Value Changed: {0}", pb1.Value); + lb1.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + + lb2.Text = string.Format("PartValue Changed: {0}", pb1.GetPartValue(part)); + lb2.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + }; + + bt1.Clicked += (s, e) => + { + var val = pb1.Value + unit; + if (val <= max) + pb1.Value = val; + }; + + bt2.Clicked += (s, e) => + { + var val = pb1.Value - unit; + if (val >= min) + { + pb1.Value = val; + } + }; + + bt3.Clicked += (s, e) => + { + var val = pb1.GetPartValue(part) + unit; + if (val <= max) + pb1.SetPartValue(part, val); + }; + + bt4.Clicked += (s, e) => + { + var val = pb1.GetPartValue(part) - unit; + if (val >= min) + { + pb1.SetPartValue(part, val); + } + }; + + table.Pack(bt1, 1, 1, 1, 1); + table.Pack(bt2, 2, 1, 1, 1); + table.Pack(pb1, 1, 2, 2, 1); + table.Pack(lb1, 1, 3, 2, 1); + table.Pack(lb2, 1, 4, 2, 1); + table.Pack(bt3, 1, 5, 1, 1); + table.Pack(bt4, 2, 5, 1, 1); + + pb1.Show(); + lb1.Show(); + lb2.Show(); + bt1.Show(); + bt2.Show(); + bt3.Show(); + bt4.Show(); + } + } +} \ No newline at end of file diff --git a/test/ElmSharp.Test/TC/Wearable/ProgressBarTest2.cs b/test/ElmSharp.Test/TC/Wearable/ProgressBarTest2.cs new file mode 100755 index 0000000..c91cb09 --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/ProgressBarTest2.cs @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ + + +namespace ElmSharp.Test.Wearable +{ + class ProgressBarTest2 : WearableTestCase + { + public override string TestName => "ProgressBarTest2"; + public override string TestDescription => "To test basic operation of ProgressBar"; + + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Scroller scroller = new Scroller(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + ScrollBlock = ScrollBlock.None, + }; + scroller.Show(); + conformant.SetContent(scroller); + + Box box = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + box.Show(); + scroller.SetContent(box); + + ProgressBar pb1 = new ProgressBar(window) + { + Text = "ProgressBar Test", + Style = "process", + Value = 0.1, + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + pb1.PlayPulse(); + pb1.Show(); + + ProgressBar pb2 = new ProgressBar(window) + { + Text = "ProgressBar Test", + Style = "process/small", + Value = 0.1, + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + pb2.PlayPulse(); + pb2.Show(); + + box.PackEnd(pb1); + box.PackEnd(pb2); + } + } +} \ No newline at end of file diff --git a/test/ElmSharp.Test/TC/Wearable/RadioTest1.cs b/test/ElmSharp.Test/TC/Wearable/RadioTest1.cs new file mode 100755 index 0000000..abdec2b --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/RadioTest1.cs @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElmSharp.Test.Wearable +{ + class RadioTest1 : WearableTestCase + { + public override string TestName => "RadioTest1"; + public override string TestDescription => "To test basic operation of Radio"; + + Label _lb1; + + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Box box = new Box(window); + conformant.SetContent(box); + box.Show(); + + Radio rd1 = new Radio(window) + { + StateValue = 1, + Text = "Value #1", + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1 + }; + Radio rd2 = new Radio(window) + { + StateValue = 2, + Text = "Value #2", + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1 + }; + Radio rd3 = new Radio(window) + { + StateValue = 3, + Text = "Value #3", + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1 + }; + rd2.SetGroup(rd1); + rd3.SetGroup(rd2); + + rd1.ValueChanged += OnRadioValueChanged; + rd2.ValueChanged += OnRadioValueChanged; + rd3.ValueChanged += OnRadioValueChanged; + + _lb1 = new Label(window) + { + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1 + }; + + box.PackEnd(_lb1); + box.PackEnd(rd1); + box.PackEnd(rd2); + box.PackEnd(rd3); + + _lb1.Show(); + rd1.Show(); + rd2.Show(); + rd3.Show(); + } + + void OnRadioValueChanged(object sender, EventArgs e) + { + _lb1.Text = string.Format("Value Changed: {0}", ((Radio)sender).GroupValue); + _lb1.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + } + } +} diff --git a/test/ElmSharp.Test/TC/Wearable/RectangleTest1.cs b/test/ElmSharp.Test/TC/Wearable/RectangleTest1.cs new file mode 100755 index 0000000..a0696a5 --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/RectangleTest1.cs @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; +using ElmSharp; + +namespace ElmSharp.Test.Wearable +{ + class RectangleTest1 : WearableTestCase + { + public override string TestName => "RectangleTest1"; + public override string TestDescription => "Add one Red Rectangle and one Orange Rectangle"; + + public override void Run(Window window) + { + Rect square = window.GetInnerSquare(); + Rectangle box1 = new Rectangle(window) + { + Color = Color.Red + }; + box1.Show(); + box1.Resize(square.Width / 2, square.Height / 2); + box1.Move(square.X, square.Y); + Rectangle box2 = new Rectangle(window) + { + Color = Color.Orange + }; + box2.Show(); + box2.Resize(square.Width / 2, square.Height / 2); + box2.Move(square.X + square.Width / 2, square.Y + square.Height / 2); + } + } +} diff --git a/test/ElmSharp.Test/TC/Wearable/ScreenInformationTest.cs b/test/ElmSharp.Test/TC/Wearable/ScreenInformationTest.cs new file mode 100755 index 0000000..92ac97c --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/ScreenInformationTest.cs @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ + +namespace ElmSharp.Test.Wearable +{ + public class ScreenInformationTest : WearableTestCase + { + public override string TestName => "ScreenInformationTest"; + public override string TestDescription => "To get screen information"; + + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Box box = new Box(window); + box.Show(); + conformant.SetContent(box); + Label label = new Label(window); + label.SetAlignment(-1, 0); + label.SetWeight(1, 0); + label.Text = string.Format("ScreenSize : {0}x{1}", window.ScreenSize.Width, window.ScreenSize.Height); + label.Show(); + box.PackEnd(label); + Label label2 = new Label(window); + label2.SetAlignment(-1, 0); + label2.SetWeight(1, 0); + label2.Text = string.Format("ScreenDPI : xdpi : {0} ydpi : {1}", window.ScreenDpi.X, window.ScreenDpi.Y); + label2.Show(); + box.PackEnd(label2); + } + } +} diff --git a/test/ElmSharp.Test/TC/Wearable/ScrollerTest1.cs b/test/ElmSharp.Test/TC/Wearable/ScrollerTest1.cs new file mode 100755 index 0000000..5d364ff --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/ScrollerTest1.cs @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; + +namespace ElmSharp.Test.Wearable +{ + public class ScrollerTest1 : WearableTestCase + { + public override string TestName => "ScrollerTest1"; + public override string TestDescription => "To test basic operation of Scroller"; + + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Scroller scroller = new Scroller(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + ScrollBlock = ScrollBlock.None, + }; + scroller.Show(); + conformant.SetContent(scroller); + + Box box = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + box.Show(); + scroller.SetContent(box); + + var rnd = new Random(); + for (int i = 0; i < 102; i++) + { + int r = rnd.Next(255); + int g = rnd.Next(255); + int b = rnd.Next(255); + Color color = Color.FromRgb(r, g, b); + Rectangle colorBox = new Rectangle(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + Color = color, + MinimumHeight = 400, + }; + colorBox.Show(); + Console.WriteLine("Height = {0}", colorBox.Geometry.Height); + box.PackEnd(colorBox); + } + scroller.Scrolled += Scroller_Scrolled; + } + + private void Scroller_Scrolled(object sender, EventArgs e) + { + Console.WriteLine("Scrolled : {0}x{1}", ((Scroller)sender).CurrentRegion.X, ((Scroller)sender).CurrentRegion.Y); + } + } +} diff --git a/test/ElmSharp.Test/TC/Wearable/ScrollerTest2.cs b/test/ElmSharp.Test/TC/Wearable/ScrollerTest2.cs new file mode 100755 index 0000000..adf2b72 --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/ScrollerTest2.cs @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; + +namespace ElmSharp.Test.Wearable +{ + public class ScrollerTest2 : WearableTestCase + { + public override string TestName => "ScrollerTest2"; + public override string TestDescription => "To test basic operation of Scroller"; + + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Box outterBox = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + IsHorizontal = false, + }; + outterBox.Show(); + Scroller scroller = new Scroller(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + ScrollBlock = ScrollBlock.Vertical, + HorizontalPageScrollLimit = 1, + }; + scroller.SetPageSize(1.0, 1.0); + scroller.Show(); + + Box box = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + IsHorizontal = true, + }; + box.Show(); + scroller.SetContent(box); + + var rnd = new Random(); + for (int i = 0; i < 102; i++) + { + int r = rnd.Next(255); + int g = rnd.Next(255); + int b = rnd.Next(255); + Color color = Color.FromRgb(r, g, b); + Rectangle colorBox = new Rectangle(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + Color = color, + MinimumWidth = window.ScreenSize.Width, + }; + colorBox.Show(); + Console.WriteLine("Height = {0}", colorBox.Geometry.Height); + box.PackEnd(colorBox); + } + + conformant.SetContent(outterBox); + outterBox.PackEnd(scroller); + + Box buttonBox = new Box(window) + { + IsHorizontal = true, + AlignmentX = -1, + AlignmentY = 0, + }; + buttonBox.Show(); + + Button prev = new Button(window) + { + AlignmentX = -1, + WeightX = 1, + Text = "Prev" + }; + Button next = new Button(window) + { + AlignmentX = -1, + WeightX = 1, + Text = "next" + }; + prev.Clicked += (s, e) => + { + scroller.ScrollTo(scroller.HorizontalPageIndex > 0 ? scroller.HorizontalPageIndex - 1: 0, scroller.VerticalPageIndex, true); + }; + next.Clicked += (s, e) => + { + scroller.ScrollTo(scroller.HorizontalPageIndex + 1, scroller.VerticalPageIndex, true); + }; + prev.Show(); + next.Show(); + buttonBox.PackEnd(prev); + buttonBox.PackEnd(next); + outterBox.PackEnd(buttonBox); + + scroller.DragStart += Scroller_DragStart; + scroller.DragStop += Scroller_DragStop; + } + + private void Scroller_DragStop(object sender, EventArgs e) + { + Console.WriteLine("Drag stop"); + } + + private void Scroller_DragStart(object sender, EventArgs e) + { + Console.WriteLine("Drag start"); + } + } +} diff --git a/test/ElmSharp.Test/TC/Wearable/ScrollerTest3.cs b/test/ElmSharp.Test/TC/Wearable/ScrollerTest3.cs new file mode 100755 index 0000000..5b403dd --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/ScrollerTest3.cs @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; + +namespace ElmSharp.Test.Wearable +{ + public class ScrollerTest3 : WearableTestCase + { + public override string TestName => "ScrollerTest3"; + public override string TestDescription => "To test ScrollTo operation of Scroller"; + + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Box outterBox = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + IsHorizontal = false, + }; + outterBox.Show(); + Scroller scroller = new Scroller(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + ScrollBlock = ScrollBlock.Vertical, + HorizontalPageScrollLimit = 1, + }; + scroller.SetPageSize(1.0, 1.0); + scroller.Show(); + + Box box = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + box.Show(); + scroller.SetContent(box); + + for (int i = 0; i < 30; i++) + { + Label addlabel = new Label(window) + { + Text = i + " Label Test", + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + }; + addlabel.Show(); + box.PackEnd(addlabel); + } + + conformant.SetContent(outterBox); + outterBox.PackEnd(scroller); + + Box buttonBox = new Box(window) + { + IsHorizontal = true, + AlignmentX = -1, + AlignmentY = 0, + }; + buttonBox.Show(); + + Button prev = new Button(window) + { + AlignmentX = -1, + WeightX = 1, + Text = "Prev" + }; + Button next = new Button(window) + { + AlignmentX = -1, + WeightX = 1, + Text = "next" + }; + prev.Clicked += (s, e) => + { + Rect region = new Rect(0, 0, scroller.Geometry.Width, scroller.Geometry.Width); + Console.WriteLine("{0} {1}\n", scroller.Geometry.Width, scroller.Geometry.Width); + scroller.ScrollTo(region, true); + }; + next.Clicked += (s, e) => + { + Rect region = new Rect(0, scroller.Geometry.Height, scroller.Geometry.Width, scroller.Geometry.Height); + Console.WriteLine("{0} {1}\n", scroller.Geometry.Width, scroller.Geometry.Width); + scroller.ScrollTo(region, true); + }; + prev.Show(); + next.Show(); + buttonBox.PackEnd(prev); + buttonBox.PackEnd(next); + outterBox.PackEnd(buttonBox); + + scroller.DragStart += Scroller_DragStart; + scroller.DragStop += Scroller_DragStop; + } + + private void Scroller_DragStop(object sender, EventArgs e) + { + Console.WriteLine("Drag stop"); + } + + private void Scroller_DragStart(object sender, EventArgs e) + { + Console.WriteLine("Drag start"); + } + } +} diff --git a/test/ElmSharp.Test/TC/Wearable/SliderTest1.cs b/test/ElmSharp.Test/TC/Wearable/SliderTest1.cs new file mode 100755 index 0000000..40342b1 --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/SliderTest1.cs @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ + +namespace ElmSharp.Test.Wearable +{ + class SliderTest1 : WearableTestCase + { + public override string TestName => "SliderTest1"; + public override string TestDescription => "To test basic operation of Slider"; + + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Box box = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + IsHorizontal = false, + }; + box.Show(); + conformant.SetContent(box); + + Slider sld1 = new Slider(window) + { + Text = "Slider Test", + IndicatorFormat = "%1.2f meters", + Minimum = 0.0, + Maximum = 100.0, + Value = 0.1, + AlignmentX = -1, + AlignmentY = 0.5, + WeightX = 1, + WeightY = 1, + IsIndicatorFocusable = true + }; + + Label lb1 = new Label(window) + { + AlignmentX = -1, + AlignmentY = 1, + WeightX = 1, + WeightY = 1 + }; + + Label lb2 = new Label(window) + { + AlignmentX = -1, + AlignmentY = 1, + WeightX = 1, + WeightY = 1, + Text = string.Format("IsIndicatorFocusable : {0}", sld1.IsIndicatorFocusable.ToString()), + }; + + Label lb3 = new Label(window) + { + AlignmentX = -1, + AlignmentY = 1, + WeightX = 1, + WeightY = 1, + Text = string.Format("IndicatorVisibleMode : {0}", sld1.IndicatorVisibleMode.ToString()), + }; + + Box buttonBox = new Box(window) + { + IsHorizontal = true, + AlignmentX = -1, + AlignmentY = 0, + }; + buttonBox.Show(); + + Button btn = new Button(window) + { + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1, + Text = "IsIndicatorFocusable" + }; + btn.Clicked += (s, e) => + { + if (sld1.IsIndicatorFocusable) + { + sld1.IsIndicatorFocusable = false; + } + else + { + sld1.IsIndicatorFocusable = true; + } + lb2.Text = string.Format("IsIndicatorFocusable : {0}", sld1.IsIndicatorFocusable.ToString()); + lb2.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + }; + + Button btn2 = new Button(window) + { + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1, + Text = "IndicatorVisibleMode" + }; + btn2.Clicked += (s, e) => + { + if (sld1.IndicatorVisibleMode == SliderIndicatorVisibleMode.Default) + { + sld1.IndicatorVisibleMode = SliderIndicatorVisibleMode.Always; + } + else if (sld1.IndicatorVisibleMode == SliderIndicatorVisibleMode.Always) + { + sld1.IndicatorVisibleMode = SliderIndicatorVisibleMode.OnFocus; + } + else if (sld1.IndicatorVisibleMode == SliderIndicatorVisibleMode.OnFocus) + { + sld1.IndicatorVisibleMode = SliderIndicatorVisibleMode.None; + } + else + { + sld1.IndicatorVisibleMode = SliderIndicatorVisibleMode.Default; + } + + lb3.Text = string.Format("IndicatorVisibleMode : {0}", sld1.IndicatorVisibleMode.ToString()); + lb3.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + }; + + sld1.Show(); + lb1.Show(); + lb2.Show(); + lb3.Show(); + btn.Show(); + btn2.Show(); + + buttonBox.PackEnd(btn); + buttonBox.PackEnd(btn2); + + box.PackEnd(lb1); + box.PackEnd(lb2); + box.PackEnd(lb3); + box.PackEnd(sld1); + box.PackEnd(buttonBox); + + lb2.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + lb3.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + + sld1.ValueChanged += (s, e) => + { + lb1.Text = string.Format("Value Changed: {0}", sld1.Value); + lb1.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + }; + } + } +} \ No newline at end of file diff --git a/test/ElmSharp.Test/TC/Wearable/SliderTest2.cs b/test/ElmSharp.Test/TC/Wearable/SliderTest2.cs new file mode 100755 index 0000000..fa9aca7 --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/SliderTest2.cs @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ + + +namespace ElmSharp.Test.Wearable +{ + class SliderTest2 : WearableTestCase + { + public override string TestName => "SliderTest2"; + public override string TestDescription => "To test basic operation of Slider"; + + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Box box = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + IsHorizontal = false, + }; + box.Show(); + conformant.SetContent(box); + + Slider sld = new Slider(window) + { + Text = "Slider Test", + IndicatorFormat = "%1.2f meters", + Minimum = 0.0, + Maximum = 100.0, + Value = 0.1, + AlignmentX = -1, + AlignmentY = 0.5, + WeightX = 1, + WeightY = 1, + IsIndicatorFocusable = true + }; + + Label Emptylb = new Label(window) + { + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1, + Text=" " + }; + + Label lb1 = new Label(window) + { + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1, + Text = string.Format("IndicatorVisibleMode={0}", sld.IndicatorVisibleMode.ToString()), + }; + lb1.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + + Label lb2 = new Label(window) + { + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1, + Text = string.Format("IsIndicatorVisible={0}", sld.IsIndicatorVisible.ToString()), + }; + lb2.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + + Box buttonBox = new Box(window) + { + IsHorizontal = true, + AlignmentX = -1, + AlignmentY = 0, + }; + buttonBox.Show(); + + Button btn1 = new Button(window) + { + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1, + Text = "IndicatorVisibleMode" + }; + btn1.Clicked += (s, e) => + { + sld.IndicatorVisibleMode = (SliderIndicatorVisibleMode)(((int)sld.IndicatorVisibleMode + 1) % 4); + lb1.Text = string.Format("IndicatorVisibleMode={0}", sld.IndicatorVisibleMode.ToString()); + lb1.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + }; + + Button btn2 = new Button(window) + { + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1, + Text = "IsIndicatorVisible" + }; + btn2.Clicked += (s, e) => + { + sld.IsIndicatorVisible = !sld.IsIndicatorVisible; + lb2.Text = string.Format("IsIndicatorVisible={0}", sld.IsIndicatorVisible.ToString()); + lb2.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + }; + + sld.Show(); + Emptylb.Show(); + lb1.Show(); + lb2.Show(); + btn1.Show(); + btn2.Show(); + + buttonBox.PackEnd(btn1); + buttonBox.PackEnd(btn2); + + box.PackEnd(Emptylb); + box.PackEnd(lb1); + box.PackEnd(lb2); + box.PackEnd(sld); + box.PackEnd(buttonBox); + + sld.ValueChanged += (s, e) => + { + lb1.Text = string.Format("IndicatorVisibleMode={0}", sld.IndicatorVisibleMode.ToString()); + lb1.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + + lb2.Text = string.Format("IsIndicatorVisible={0}", sld.IsIndicatorVisible.ToString()); + lb2.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + }; + } + } +} \ No newline at end of file diff --git a/test/ElmSharp.Test/TC/Wearable/SpinnerTest1.cs b/test/ElmSharp.Test/TC/Wearable/SpinnerTest1.cs new file mode 100755 index 0000000..d2cf348 --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/SpinnerTest1.cs @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; + +namespace ElmSharp.Test.Wearable +{ + class SpinnerTest1 : WearableTestCase + { + public override string TestName => "SpinnerTest1"; + public override string TestDescription => "To test basic operation of Spinner"; + + public override void Run(Window window) + { + Rect square = window.GetInnerSquare(); + + Spinner spn1 = new Spinner(window) + { + Text = "Slider Test", + LabelFormat = "%1.2f Value", + Minimum = 1, + Maximum = 12, + Value = 1.5, + Step = 0.5, + Interval = 0.5, + AlignmentX = -1, + AlignmentY = 0.5, + WeightX = 1, + WeightY = 1 + }; + spn1.AddSpecialValue(5, "Five !!!!"); + + Label lb1 = new Label(window) + { + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 1 + }; + + spn1.Geometry = new Rect(square.X, square.Y, square.Width , square.Height / 4); + spn1.Show(); + + lb1.Geometry = new Rect(square.X, square.Y + square.Width * 2 / 4 , square.Width, square.Height / 4); + lb1.Show(); + + spn1.ValueChanged += (s, e) => + { + lb1.Text = string.Format("Value Changed: {0}", spn1.Value); + lb1.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'"; + }; + } + } +} diff --git a/test/ElmSharp.Test/TC/Wearable/TransitTest.cs b/test/ElmSharp.Test/TC/Wearable/TransitTest.cs new file mode 100755 index 0000000..36d41f3 --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/TransitTest.cs @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; +using ElmSharp; + +namespace ElmSharp.Test.Wearable +{ + class TransitTest : WearableTestCase + { + public override string TestName => "TransitTest"; + public override string TestDescription => "To test basic operation of Transit"; + + Transit CreateTransit() + { + Transit transit = new Transit(); + transit.Deleted += (s, e) => { Console.WriteLine("Transit Deleted"); }; + transit.Repeat = 1; + transit.AutoReverse = true; + transit.Duration = 1; + return transit; + } + + public override void Run(Window window) + { + Rect square = window.GetInnerSquare(); + Button button1 = new Button(window) { + Text = "Effect", + }; + button1.Move(square.X, square.Y); + button1.Resize(square.Width / 2, square.Height / 2); + button1.Show(); + + Button button2 = new Button(window) + { + Text = "Chain Effect", + }; + button2.Move(square.X + square.Width / 2, square.Y + square.Height / 2); + button2.Resize(square.Width / 2, square.Height / 2); + button2.Show(); + + Point begin = new Point(); + begin.X = begin.Y = 0; + Point end = new Point(); + end.X = end.Y = square.Height / 2; + TranslationEffect translation = new TranslationEffect(begin, end); + translation.EffectEnded += (s, e) => { Console.WriteLine("Translation Effect Ended"); }; + + RotationEffect rotation = new RotationEffect(0, 180); + rotation.EffectEnded += (s, e) => { Console.WriteLine("Rotation Effect Ended"); }; + + button1.Clicked += (s, e) => { + Transit transit1 = CreateTransit(); + transit1.Objects.Add(button1); + transit1.Objects.Add(button2); + transit1.AddEffect(translation); + transit1.AddEffect(rotation); + transit1.Go(); + }; + + button2.Clicked += (s, e) => { + Transit transit1 = CreateTransit(); + transit1.Objects.Add(button1); + transit1.AddEffect(translation); + transit1.AddEffect(rotation); + + Transit transit2 = CreateTransit(); + transit2.Objects.Add(button2); + transit2.AddEffect(translation); + transit2.AddEffect(rotation); + + transit1.Chains.Add(transit2); + transit1.Go(); + }; + } + } +} \ No newline at end of file diff --git a/test/ElmSharp.Test/TC/Wearable/WindowInternalTest.cs b/test/ElmSharp.Test/TC/Wearable/WindowInternalTest.cs new file mode 100755 index 0000000..2307fb5 --- /dev/null +++ b/test/ElmSharp.Test/TC/Wearable/WindowInternalTest.cs @@ -0,0 +1,97 @@ +using Tizen.Applications; +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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; + +namespace ElmSharp.Test.Wearable +{ + class WindowInternalTest : WearableTestCase + { + public override string TestName => "WindowInternalTest"; + public override string TestDescription => "Window Test"; + + public override void Run(Window window) + { + var firstWindow = (Application.Current as TestRunner)?._firstPageWindow; + firstWindow.Hide(); + firstWindow.Unrealize(); + + Rect square = window.GetInnerSquare(); + + Button button1 = new Button(window) { + Text = "Iconified", + }; + button1.Resize(square.Width, square.Height / 3); + button1.Move(square.X, square.Y); + button1.Show(); + + button1.Clicked += (e, o) => + { + window.Iconified = true; + }; + + Button button2 = new Button(window) + { + Text = "WinKeyGrab", + }; + button2.Resize(square.Width, square.Height / 3); + button2.Move( square.X, square.Y + square.Height / 3); + button2.Show(); + + button2.Clicked += (e, o) => + { + Log.Debug("@@KeyGrab"); + window.KeyGrab(EvasKeyEventArgs.PlatformHomeButtonName, true); + window.WinKeyGrab(EvasKeyEventArgs.PlatformHomeButtonName, KeyGrabMode.Exclusive); + }; + + Button button3 = new Button(window) + { + Text = "WinUnKeyGrab", + }; + button3.Resize(square.Width, square.Height / 3); + button3.Move(square.X, square.Y + square.Height * 2 / 3); + button3.Show(); + + button3.Clicked += (e, o) => + { + Log.Debug("@@UnKeyGrab"); + window.WinKeyUngrab(EvasKeyEventArgs.PlatformHomeButtonName); + window.KeyUngrab(EvasKeyEventArgs.PlatformHomeButtonName); + + }; + window.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, true); + EventHandler handler = (s, e) => + { + Log.Debug("@@KeyDown start" + e.KeyName); + + if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName) + { + Application.Current.Exit(); + } + if (e.KeyName == EvasKeyEventArgs.PlatformHomeButtonName) + { + Log.Debug("@@KeyDown OK : " + window.Iconified); + window.Iconified = !window.Iconified; + } + }; + + window.KeyUp += handler; + } + + } +} -- 2.7.4