Skip to content

Commit

Permalink
[Xamarin.Android.NUnitLite] Import from monodroid/ae417a99 (#13)
Browse files Browse the repository at this point in the history
Xamarin.Android.NUnitLite is a copy of NUnitLite, modified for use
with Xamarin.Android and to provide a Xamarin.Android test runner GUI.
  • Loading branch information
jonpryor authored and dellis1972 committed May 10, 2016
1 parent 972c1ac commit 8b0d145
Show file tree
Hide file tree
Showing 285 changed files with 39,181 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
<AndroidFrameworkVersion Condition=" '$(AndroidFrameworkVersion)' == '' ">v6.0</AndroidFrameworkVersion>
<AndroidToolchainCacheDirectory Condition=" '$(AndroidToolchainCacheDirectory)' == '' ">$(HOME)\android-archives</AndroidToolchainCacheDirectory>
<AndroidToolchainDirectory Condition=" '$(AndroidToolchainDirectory)' == '' ">$(HOME)\android-toolchain</AndroidToolchainDirectory>
<AndroidSdkDirectory>$(AndroidToolchainDirectory)\sdk</AndroidSdkDirectory>
<AndroidNdkDirectory>$(AndroidToolchainDirectory)\ndk</AndroidNdkDirectory>
</PropertyGroup>
</Project>
15 changes: 14 additions & 1 deletion Xamarin.Android.sln
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "monodroid", "src\monodroid\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "api-xml-adjuster", "tools\api-xml-adjuster\api-xml-adjuster.csproj", "{8A6CB07C-E493-4A4F-AB94-038645A27118}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{99CBCF85-E4EB-41C8-9089-1A2B740681F0}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.NUnitLite", "src\Xamarin.Android.NUnitLite\Xamarin.Android.NUnitLite.csproj", "{4D603AA3-3BFD-43C8-8050-0CD6C2601126}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -196,6 +196,18 @@ Global
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.Release|AnyCPU.Build.0 = Release|Any CPU
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationDebug|AnyCPU.ActiveCfg = Debug|Any CPU
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationDebug|AnyCPU.Build.0 = Debug|Any CPU
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationRelease|AnyCPU.ActiveCfg = Debug|Any CPU
{4D603AA3-3BFD-43C8-8050-0CD6C2601126}.XAIntegrationRelease|AnyCPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
Expand All @@ -221,6 +233,7 @@ Global
{D48EE8D0-0A0A-4493-AEF5-DAF5F8CF86AD} = {864062D3-A415-4A6F-9324-5820237BA058}
{53EE4C57-1C03-405A-8243-8DA539546C88} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{8A6CB07C-E493-4A4F-AB94-038645A27118} = {864062D3-A415-4A6F-9324-5820237BA058}
{4D603AA3-3BFD-43C8-8050-0CD6C2601126} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0
Expand Down
72 changes: 72 additions & 0 deletions src/Xamarin.Android.NUnitLite/Gui/Activities/OptionsActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// Copyright 2011-2012 Xamarin Inc.
//
// 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 Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Android.Views;
using Android.Widget;

namespace Xamarin.Android.NUnitLite {

[Activity (Label = "Options", WindowSoftInputMode = SoftInput.AdjustPan,
ConfigurationChanges = ConfigChanges.KeyboardHidden | ConfigChanges.Orientation)]
internal class OptionsActivity : Activity {
CheckBox remote;
TextView host_name;
TextView host_port;

protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.options);

Options options = AndroidRunner.Runner.Options;
remote = FindViewById<CheckBox> (Resource.Id.OptionRemoteServer);
remote.Checked = options.EnableNetwork;
host_name = FindViewById<EditText> (Resource.Id.OptionHostName);
host_name.Text = options.HostName;
host_port = FindViewById<EditText> (Resource.Id.OptionPort);
host_port.Text = options.HostPort.ToString ();

base.OnCreate (bundle);
}

int GetPort ()
{
int port;
ushort p;
if (UInt16.TryParse (host_port.Text, out p))
port = p;
else
port = -1;
return port;
}

protected override void OnPause ()
{
Options options = AndroidRunner.Runner.Options;
options.EnableNetwork = remote.Checked;
options.HostName = host_name.Text;
options.HostPort = GetPort ();
options.Save (this);
base.OnPause ();
}
}
}
54 changes: 54 additions & 0 deletions src/Xamarin.Android.NUnitLite/Gui/Activities/TestResultActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Text.Method;
using NUnit.Framework.Internal;
using NUnitTest = NUnit.Framework.Internal.Test;

namespace Xamarin.Android.NUnitLite
{
[Activity (Label = "Test Result")]
internal class TestResultActivity : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

// Create your application here
SetContentView (Resource.Layout.test_result);

var testName = this.Intent.GetStringExtra ("test");
var parentSuiteName = testName.Substring (0, testName.LastIndexOf ('.'));

FindViewById<TextView> (Resource.Id.ResultRunSingleMethodTest).Click += delegate {
AndroidRunner.Runner.Run ((NUnitTest) AndroidRunner.Suites [parentSuiteName].Tests.First (t => t.FullName == testName), this);
UpdateData (AndroidRunner.Results [testName]);
};
if (AndroidRunner.Results.ContainsKey (testName))
UpdateData (AndroidRunner.Results [testName]);
else
FindViewById<TextView> (Resource.Id.ResultFullName).Text = testName;
}

void UpdateData (TestResult test)
{
if (test == null)
return; // no result to fill
FindViewById<TextView> (Resource.Id.ResultFullName).Text = test.FullName;
FindViewById<TextView> (Resource.Id.ResultResultState).Text = test.ResultState.ToString ();
FindViewById<TextView> (Resource.Id.ResultMessage).Text= test.Message;
FindViewById<TextView> (Resource.Id.ResultStackTrace).Text = test.StackTrace;
FindViewById<TextView> (Resource.Id.ResultStackTrace).MovementMethod = new ScrollingMovementMethod ();
}
}
}

Loading

0 comments on commit 8b0d145

Please sign in to comment.