aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Russell <crussell@canonical.com>2009-12-12 12:20:52 -0600
committerCody Russell <crussell@canonical.com>2009-12-12 12:20:52 -0600
commit59526b689303cde25721d0a1fdcafdb371fdddba (patch)
treeee7a1bde4ce2e89942fa8bc2b3e3515143a264eb
parented4810839b0bd16af47201bae84524088b9ef178 (diff)
downloadayatana-indicator-application-59526b689303cde25721d0a1fdcafdb371fdddba.tar.gz
ayatana-indicator-application-59526b689303cde25721d0a1fdcafdb371fdddba.tar.bz2
ayatana-indicator-application-59526b689303cde25721d0a1fdcafdb371fdddba.zip
Initial stab at setting up test/example fu
-rw-r--r--bindings/mono/Makefile.am14
-rw-r--r--bindings/mono/TestIndicator.cs82
-rw-r--r--bindings/mono/examples/IndicatorExample.cs36
-rw-r--r--bindings/mono/examples/Makefile.am12
-rwxr-xr-xbindings/mono/examples/indicator-example.in2
-rw-r--r--configure.ac4
6 files changed, 149 insertions, 1 deletions
diff --git a/bindings/mono/Makefile.am b/bindings/mono/Makefile.am
index a8444ea..ef03f7e 100644
--- a/bindings/mono/Makefile.am
+++ b/bindings/mono/Makefile.am
@@ -1,6 +1,10 @@
+SUBDIRS = . examples
+
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = appindicator-sharp-0.1.pc
+TEST = AppIndicator.Test.dll
+
API = libappindicator-api.xml
RAW_API = libappindicator-api.raw
METADATA = libappindicator-api.metadata
@@ -9,11 +13,14 @@ ASSEMBLY = appindicator-sharp.dll
TARGET = $(ASSEMBLY) $(ASSEMBLY).config
assemblydir = $(libdir)/appindicator-sharp
assembly_DATA = $(TARGET)
-CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb generated-stamp generated/*.cs $(API) $(RAW_API)
+CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb generated-stamp generated/*.cs $(API) $(RAW_API) $(TEST)
DISTCLEANFILES = $(ASSEMBLY).config
EXTRA_DIST = $(RAW_API) $(METADATA) appindicator-sharp-0.1.pc.in appindicator-sharp.dll.config.in app-indicator.sources.xml
+TEST_SOURCES = TestIndicator.cs
+
references = $(GTK_SHARP_LIBS)
+test_references = $(GTK_SHARP_LIBS) $(NUNIT_LIBS) -r:$(ASSEMBLY)
$(RAW_API): app-indicator.sources.xml
$(GAPI_PARSER) app-indicator.sources.xml
@@ -37,3 +44,8 @@ generated-stamp: $(API)
$(ASSEMBLY): generated-stamp
@rm -f $(ASSEMBLY).mdb
$(CSC) $(CSFLAGS) -nowarn:0169,0612,0618 -unsafe -out:$(ASSEMBLY) -target:library $(references) $(GENERATED_SOURCES)
+
+$(TEST): $(ASSEMBLY)
+ $(CSC) -out:$(TEST) -target:library $(test_references) $(TEST_SOURCES)
+
+all: $(TEST)
diff --git a/bindings/mono/TestIndicator.cs b/bindings/mono/TestIndicator.cs
new file mode 100644
index 0000000..3127342
--- /dev/null
+++ b/bindings/mono/TestIndicator.cs
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2009 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Cody Russell <cody.russell@canonical.com>
+ */
+
+using System;
+using GLib;
+using Gtk;
+using AppIndicator;
+
+using NUnit.Framework;
+
+namespace Ayatana.AppIndicator.Test
+{
+ [TestFixture]
+ public class IndicatorTest
+ {
+ ApplicationIndicator indicator;
+
+ private void Update ()
+ {
+ while (MainContext.Pending ())
+ MainContext.Iteration(true);
+ }
+
+ [SetUp]
+ public void Init ()
+ {
+ Application.Init ();
+
+ Console.WriteLine ("Init()");
+
+ indicator = new ApplicationIndicator ("my-id", "my-name", Category.ApplicationStatus);
+
+ Console.WriteLine ("Created indicator");
+
+ Update();
+ }
+
+ [Test]
+ public void TestProperties ()
+ {
+ Console.WriteLine ("TestProperties()");
+
+ Assert.AreNotSame (indicator, null);
+
+ Assert.AreEqual (indicator.IconName, "my-name");
+ Assert.AreEqual (indicator.ID, "my-id");
+ Assert.AreEqual (indicator.Status, Category.ApplicationStatus);
+
+ Console.WriteLine ("End..");
+ }
+
+ [Test]
+ public void TestSetProperties ()
+ {
+ Console.WriteLine ("TestSetProperties");
+
+ indicator.Status = Status.Attention;
+ indicator.AttentionIconName = "my-attention-name";
+
+ Assert.AreEqual (indicator.Status, Status.Attention);
+ Assert.AreEqual (indicator.AttentionIconName, "my-attention-name");
+
+ Console.WriteLine ("End..");
+ }
+ }
+} \ No newline at end of file
diff --git a/bindings/mono/examples/IndicatorExample.cs b/bindings/mono/examples/IndicatorExample.cs
new file mode 100644
index 0000000..0cb72a1
--- /dev/null
+++ b/bindings/mono/examples/IndicatorExample.cs
@@ -0,0 +1,36 @@
+using Gtk;
+using AppIndicator;
+
+public class IndicatorExample
+{
+ public static void Main ()
+ {
+ Application.Init ();
+
+ Window win = new Window ("Test");
+ win.Resize (200, 200);
+
+ Label label = new Label ();
+ label.Text = "Hello, world!";
+
+ win.Add (label);
+
+ ApplicationIndicator indicator = new ApplicationIndicator ("my-id",
+ "my-name",
+ Category.ApplicationStatus);
+
+ indicator.Status = Status.Attention;
+
+ /*
+ Menu menu = new Menu ();
+ menu.Append (new MenuItem ("Foo"));
+ menu.Append (new MenuItem ("Bar"));
+
+ indicator.Menu = menu;
+ */
+
+ win.ShowAll ();
+
+ Application.Run ();
+ }
+} \ No newline at end of file
diff --git a/bindings/mono/examples/Makefile.am b/bindings/mono/examples/Makefile.am
new file mode 100644
index 0000000..cb7f268
--- /dev/null
+++ b/bindings/mono/examples/Makefile.am
@@ -0,0 +1,12 @@
+ASSEMBLY = IndicatorExample.exe
+CSFILES = IndicatorExample.cs
+CLEANFILES = $(ASSEMBLY)
+
+EXTRA_DIST = $(CSFILES)
+
+references = $(GTK_SHARP_LIBS) -r:$(top_builddir)/bindings/mono/appindicator-sharp.dll
+
+$(ASSEMBLY):
+ $(CSC) $(CSFLAGS) -out:$(ASSEMBLY) -target:exe $(references) $(CSFILES)
+
+all: $(ASSEMBLY) \ No newline at end of file
diff --git a/bindings/mono/examples/indicator-example.in b/bindings/mono/examples/indicator-example.in
new file mode 100755
index 0000000..3eca155
--- /dev/null
+++ b/bindings/mono/examples/indicator-example.in
@@ -0,0 +1,2 @@
+#!/bin/sh
+MONO_PATH=@top_builddir@/bindings/mono @top_builddir@/bindings/mono/examples/IndicatorExample.exe
diff --git a/configure.ac b/configure.ac
index fc1381c..ca1793a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,6 +96,8 @@ AC_SUBST(GAPI_CODEGEN)
AC_PATH_PROG(GAPI_FIXUP, gapi2-fixup, no)
AC_SUBST(GAPI_FIXUP)
+PKG_CHECK_MODULES(NUNIT, nunit-2.4 >= 2.4.7)
+AC_SUBST(NUNIT_LIBS)
###########################
# Check to see if we're local
@@ -141,6 +143,8 @@ bindings/Makefile
bindings/mono/Makefile
bindings/mono/appindicator-sharp.dll.config
bindings/mono/appindicator-sharp-0.1.pc
+bindings/mono/examples/Makefile
+bindings/mono/examples/indicator-example
data/Makefile
tests/Makefile
example/Makefile