Release 9.0.0.16564
[platform/core/csapi/tizenfx.git] / test / Tizen.MachineLearning.Inference.Test / App.cs
1 /*
2  *  Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  */
16
17 using System;
18 using Log = Tizen.Log;
19 using Xamarin.Forms;
20 using Tizen.MachineLearning.Inference.Test;
21
22 namespace XamarinForTizen.Tizen
23 {
24     public class App : Application
25     {
26         Button btnPipeline;
27         Button btnSingle;
28         Button btnTensorsInfo;
29         Label lblResult;
30         
31         
32         public App()
33         {
34             btnPipeline = new Button
35             {
36                 Text = "Pipeline Test",
37                 HorizontalOptions = LayoutOptions.FillAndExpand,
38                 VerticalOptions = LayoutOptions.StartAndExpand,
39             };
40             btnPipeline.Clicked += OnBtnPilelineClicked;
41
42             btnSingle = new Button
43             {
44                 Text = "Single Test",
45                 HorizontalOptions = LayoutOptions.FillAndExpand,
46                 VerticalOptions = LayoutOptions.StartAndExpand,
47             };
48             btnSingle.Clicked += OnBtnSingleClicked;
49
50             btnTensorsInfo = new Button
51             {
52                 Text = "TensorsInfo Test",
53                 HorizontalOptions = LayoutOptions.FillAndExpand,
54                 VerticalOptions = LayoutOptions.StartAndExpand,
55             };
56             btnTensorsInfo.Clicked += OnBtnTensorsInfoClicked;
57
58             lblResult = new Label
59             {
60                 Text = "",
61                 HorizontalOptions = LayoutOptions.FillAndExpand,
62             };
63             // The root page of your application
64             MainPage = new ContentPage
65             {
66                 Content = new StackLayout
67                 {
68                     VerticalOptions = LayoutOptions.Start,
69                     Children = {
70                         btnPipeline,
71                         btnSingle,
72                         btnTensorsInfo,
73                         lblResult,
74                     }
75                 }
76             };
77         }
78
79         protected override void OnStart()
80         {
81             // Handle when your app starts
82         }
83
84         protected override void OnSleep()
85         {
86             // Handle when your app sleeps
87         }
88
89         protected override void OnResume()
90         {
91             // Handle when your app resumes
92         }
93
94         private void OnBtnPilelineClicked(object s, EventArgs e)
95         {
96             string retMsg = "";
97             retMsg += "Pipeline Test Started\n\n";
98
99             retMsg += "\nPipeline Test Done";
100
101             lblResult.Text = retMsg;
102         }
103
104         private void OnBtnSingleClicked(object s, EventArgs e)
105         {
106             string msg = "Single Test Started\n";
107
108             msg += "  * BasicSingleTest_Success00: ";
109             msg += SingleShotTest.BasicSingleTest_Success00() ? "OK\n" : "Failed\n";
110
111             msg += "Single Test is Done\n";
112
113             lblResult.Text = msg;
114         }
115
116         private void OnBtnTensorsInfoClicked(object s, EventArgs e)
117         {
118             string msg = "TensorsInfo Test Started\n";
119             
120             msg += "  * BasicTensorTest_Success00: ";
121             msg += TensorsInfoTest.BasicTensorTest_Success00() ? "OK\n" : "Failed\n";
122
123             msg += "  * BasicTensorTest_Success01: ";
124             msg += TensorsInfoTest.BasicTensorTest_Success01() ? "OK\n" : "Failed\n";
125
126             msg += "  * BasicTensorTest_Success02: ";
127             msg += TensorsInfoTest.BasicTensorTest_Success02() ? "OK\n" : "Failed\n";
128
129             lblResult.Text = msg;
130         }
131     }
132 }