-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.NUnitLite] Import from monodroid/ae417a99 (#13)
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
1 parent
972c1ac
commit 8b0d145
Showing
285 changed files
with
39,181 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/Xamarin.Android.NUnitLite/Gui/Activities/OptionsActivity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
54
src/Xamarin.Android.NUnitLite/Gui/Activities/TestResultActivity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 (); | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.