Skip to content

Commit ac3534d

Browse files
committed
[Xamarin.Android.NUnitLite] Import from monodroid/ae417a99
Xamarin.Android.NUnitLite is a copy of NUnitLite, modified for use with Xamarin.Android and to provide a Xamarin.Android test runner GUI.
1 parent a3dfd4c commit ac3534d

File tree

285 files changed

+39184
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+39184
-2
lines changed

Configuration.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@
1616
<AndroidFrameworkVersion Condition=" '$(AndroidFrameworkVersion)' == '' ">v6.0</AndroidFrameworkVersion>
1717
<AndroidToolchainCacheDirectory Condition=" '$(AndroidToolchainCacheDirectory)' == '' ">$(HOME)\android-archives</AndroidToolchainCacheDirectory>
1818
<AndroidToolchainDirectory Condition=" '$(AndroidToolchainDirectory)' == '' ">$(HOME)\android-toolchain</AndroidToolchainDirectory>
19+
<AndroidSdkDirectory>$(AndroidToolchainDirectory)\sdk</AndroidSdkDirectory>
20+
<AndroidNdkDirectory>$(AndroidToolchainDirectory)\ndk</AndroidNdkDirectory>
1921
</PropertyGroup>
2022
</Project>

Xamarin.Android.sln

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "monodroid", "src\monodroid\
5353
EndProject
5454
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "api-xml-adjuster", "tools\api-xml-adjuster\api-xml-adjuster.csproj", "{8A6CB07C-E493-4A4F-AB94-038645A27118}"
5555
EndProject
56-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{99CBCF85-E4EB-41C8-9089-1A2B740681F0}"
56+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.NUnitLite", "src\Xamarin.Android.NUnitLite\Xamarin.Android.NUnitLite.csproj", "{4D603AA3-3BFD-43C8-8050-0CD6C2601126}"
5757
EndProject
5858
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "samples\HelloWorld\HelloWorld.csproj", "{2305B00D-DE81-4744-B0DA-357835CAFE5A}"
5959
EndProject
60+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{99CBCF85-E4EB-41C8-9089-1A2B740681F0}"
61+
EndProject
6062
Global
6163
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6264
Debug|AnyCPU = Debug|AnyCPU
@@ -210,6 +212,18 @@ Global
210212
{2305B00D-DE81-4744-B0DA-357835CAFE5A}.XAIntegrationDebug|AnyCPU.Build.0 = Debug|Any CPU
211213
{2305B00D-DE81-4744-B0DA-357835CAFE5A}.XAIntegrationRelease|AnyCPU.ActiveCfg = Debug|Any CPU
212214
{2305B00D-DE81-4744-B0DA-357835CAFE5A}.XAIntegrationRelease|AnyCPU.Build.0 = Debug|Any CPU
215+
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
216+
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.Debug|AnyCPU.Build.0 = Debug|Any CPU
217+
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.Release|AnyCPU.ActiveCfg = Release|Any CPU
218+
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.Release|AnyCPU.Build.0 = Release|Any CPU
219+
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
220+
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
221+
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
222+
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
223+
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationDebug|AnyCPU.ActiveCfg = Debug|Any CPU
224+
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationDebug|AnyCPU.Build.0 = Debug|Any CPU
225+
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationRelease|AnyCPU.ActiveCfg = Debug|Any CPU
226+
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationRelease|AnyCPU.Build.0 = Debug|Any CPU
213227
EndGlobalSection
214228
GlobalSection(NestedProjects) = preSolution
215229
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
@@ -235,7 +249,8 @@ Global
235249
{D48EE8D0-0A0A-4493-AEF5-DAF5F8CF86AD} = {864062D3-A415-4A6F-9324-5820237BA058}
236250
{53EE4C57-1C03-405A-8243-8DA539546C88} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
237251
{8A6CB07C-E493-4A4F-AB94-038645A27118} = {864062D3-A415-4A6F-9324-5820237BA058}
238-
{2305B00D-DE81-4744-B0DA-357835CAFE5A} = {99CBCF85-E4EB-41C8-9089-1A2B740681F0}
252+
{4D603AA3-3BFD-43C8-8050-0CD6C2601126} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
253+
{2305B00D-DE81-4744-B0DA-357835CAFE5A} = {99CBCF85-E4EB-41C8-9089-1A2B740681F0}
239254
EndGlobalSection
240255
GlobalSection(MonoDevelopProperties) = preSolution
241256
Policies = $0
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//
2+
// Copyright 2011-2012 Xamarin Inc.
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+
19+
using Android.App;
20+
using Android.Content;
21+
using Android.Content.PM;
22+
using Android.OS;
23+
using Android.Views;
24+
using Android.Widget;
25+
26+
namespace Xamarin.Android.NUnitLite {
27+
28+
[Activity (Label = "Options", WindowSoftInputMode = SoftInput.AdjustPan,
29+
ConfigurationChanges = ConfigChanges.KeyboardHidden | ConfigChanges.Orientation)]
30+
internal class OptionsActivity : Activity {
31+
CheckBox remote;
32+
TextView host_name;
33+
TextView host_port;
34+
35+
protected override void OnCreate (Bundle bundle)
36+
{
37+
base.OnCreate (bundle);
38+
SetContentView (Resource.Layout.options);
39+
40+
Options options = AndroidRunner.Runner.Options;
41+
remote = FindViewById<CheckBox> (Resource.Id.OptionRemoteServer);
42+
remote.Checked = options.EnableNetwork;
43+
host_name = FindViewById<EditText> (Resource.Id.OptionHostName);
44+
host_name.Text = options.HostName;
45+
host_port = FindViewById<EditText> (Resource.Id.OptionPort);
46+
host_port.Text = options.HostPort.ToString ();
47+
48+
base.OnCreate (bundle);
49+
}
50+
51+
int GetPort ()
52+
{
53+
int port;
54+
ushort p;
55+
if (UInt16.TryParse (host_port.Text, out p))
56+
port = p;
57+
else
58+
port = -1;
59+
return port;
60+
}
61+
62+
protected override void OnPause ()
63+
{
64+
Options options = AndroidRunner.Runner.Options;
65+
options.EnableNetwork = remote.Checked;
66+
options.HostName = host_name.Text;
67+
options.HostPort = GetPort ();
68+
options.Save (this);
69+
base.OnPause ();
70+
}
71+
}
72+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
7+
using Android.App;
8+
using Android.Content;
9+
using Android.OS;
10+
using Android.Runtime;
11+
using Android.Views;
12+
using Android.Widget;
13+
using Android.Text.Method;
14+
using NUnit.Framework.Internal;
15+
using NUnitTest = NUnit.Framework.Internal.Test;
16+
17+
namespace Xamarin.Android.NUnitLite
18+
{
19+
[Activity (Label = "Test Result")]
20+
internal class TestResultActivity : Activity
21+
{
22+
protected override void OnCreate (Bundle bundle)
23+
{
24+
base.OnCreate (bundle);
25+
26+
// Create your application here
27+
SetContentView (Resource.Layout.test_result);
28+
29+
var testName = this.Intent.GetStringExtra ("test");
30+
var parentSuiteName = testName.Substring (0, testName.LastIndexOf ('.'));
31+
32+
FindViewById<TextView> (Resource.Id.ResultRunSingleMethodTest).Click += delegate {
33+
AndroidRunner.Runner.Run ((NUnitTest) AndroidRunner.Suites [parentSuiteName].Tests.First (t => t.FullName == testName), this);
34+
UpdateData (AndroidRunner.Results [testName]);
35+
};
36+
if (AndroidRunner.Results.ContainsKey (testName))
37+
UpdateData (AndroidRunner.Results [testName]);
38+
else
39+
FindViewById<TextView> (Resource.Id.ResultFullName).Text = testName;
40+
}
41+
42+
void UpdateData (TestResult test)
43+
{
44+
if (test == null)
45+
return; // no result to fill
46+
FindViewById<TextView> (Resource.Id.ResultFullName).Text = test.FullName;
47+
FindViewById<TextView> (Resource.Id.ResultResultState).Text = test.ResultState.ToString ();
48+
FindViewById<TextView> (Resource.Id.ResultMessage).Text= test.Message;
49+
FindViewById<TextView> (Resource.Id.ResultStackTrace).Text = test.StackTrace;
50+
FindViewById<TextView> (Resource.Id.ResultStackTrace).MovementMethod = new ScrollingMovementMethod ();
51+
}
52+
}
53+
}
54+

0 commit comments

Comments
 (0)