Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
TestSuiteActivity.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under Apache 2.0 License. See LICENSE.md for details.
3 //
4 // Copyright 2011-2012 Xamarin Inc.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 
19 using System;
20 
21 using Android.App;
22 using Android.OS;
23 using Android.Widget;
24 
25 using MonoDroid.Dialog;
26 using NUnit.Framework.Api;
27 using NUnit.Framework.Internal;
28 
29 namespace Android.NUnitLite.UI {
30 
31  [Activity (Label = "Tests")]
32  public class TestSuiteActivity : Activity {
33 
34  string test_suite;
35  TestSuite suite;
36  Section main;
37 
38  protected override void OnCreate (Bundle bundle)
39  {
40  base.OnCreate (bundle);
41 
42  test_suite = Intent.GetStringExtra ("TestSuite");
43  suite = AndroidRunner.Suites [test_suite];
44 
45  var menu = new RootElement (String.Empty);
46 
47  while (suite.Tests.Count == 1 && (suite.Tests[0] is TestSuite))
48  suite = (TestSuite)suite.Tests[0];
49 
50  main = new Section(suite.FullName ?? suite.Name);
51  foreach (ITest test in suite.Tests) {
52  TestSuite ts = test as TestSuite;
53  if (ts != null)
54  main.Add (new TestSuiteElement (ts));
55  else
56  main.Add (new TestCaseElement (test));
57  }
58  menu.Add (main);
59 
60  Section options = new Section () {
61  new ActionElement ("Run all", Run),
62  };
63  menu.Add (options);
64 
65  var da = new DialogAdapter (this, menu);
66  var lv = new ListView (this) {
67  Adapter = da
68  };
69  SetContentView (lv);
70  }
71 
72  public async void Run ()
73  {
74  AndroidRunner runner = AndroidRunner.Runner;
75  if (!runner.OpenWriter ("Run " + test_suite, this))
76  return;
77 
78  try {
79  foreach (NUnit.Framework.Internal.Test test in suite.Tests)
80  {
81  await runner.Run(test);
82  }
83  }
84  finally {
85  runner.CloseWriter ();
86  }
87 
88  foreach (TestElement te in main) {
89  te.Update ();
90  }
91  }
92  }
93 }
override void OnCreate(Bundle bundle)
bool OpenWriter(string message, Context activity)
Sections contain individual Element instances that are rendered by MonoDroid.Dialog ...
Definition: Section.cs:28