Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/simulator/data/LICENSE7
-rw-r--r--tests/simulator/data/chaitanya.jpgbin1653 -> 0 bytes
-rw-r--r--tests/simulator/data/kiu.jpgbin1364 -> 0 bytes
-rw-r--r--tests/simulator/data/penelope.jpgbin1577 -> 0 bytes
-rw-r--r--tests/simulator/demo/chaitanya.py24
-rw-r--r--tests/simulator/demo/others.py37
-rw-r--r--tests/simulator/demo/penelope.py24
-rwxr-xr-xtests/simulator/simulator35
-rw-r--r--tests/sketch/Makefile.am6
-rw-r--r--tests/sketch/__init__.py0
-rw-r--r--tests/sketch/sketch.activity6
-rw-r--r--tests/sketch/sketchactivity.py234
12 files changed, 0 insertions, 373 deletions
diff --git a/tests/simulator/data/LICENSE b/tests/simulator/data/LICENSE
deleted file mode 100644
index e80f60b..0000000
--- a/tests/simulator/data/LICENSE
+++ /dev/null
@@ -1,7 +0,0 @@
-This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
-
-Attributions:
-
-chaitanya.jpg http://www.flickr.com/photos/meanestindian/166408558/
-penelope.jpg http://www.flickr.com/photos/gagah/9257515/
-kiu.jpg http://flickr.com/photos/31072589@N00/139234295/
diff --git a/tests/simulator/data/chaitanya.jpg b/tests/simulator/data/chaitanya.jpg
deleted file mode 100644
index aecaf81..0000000
--- a/tests/simulator/data/chaitanya.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/simulator/data/kiu.jpg b/tests/simulator/data/kiu.jpg
deleted file mode 100644
index 1beca11..0000000
--- a/tests/simulator/data/kiu.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/simulator/data/penelope.jpg b/tests/simulator/data/penelope.jpg
deleted file mode 100644
index 0d81097..0000000
--- a/tests/simulator/data/penelope.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/simulator/demo/chaitanya.py b/tests/simulator/demo/chaitanya.py
deleted file mode 100644
index 7d374a3..0000000
--- a/tests/simulator/demo/chaitanya.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (C) 2006, Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY 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, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-from sugar.simulator import Bot
-
-bot = Bot()
-bot.name = 'chaitanya'
-
-bot.share_chat('giraffes', 'All About Giraffes')
-
-bot.start()
diff --git a/tests/simulator/demo/others.py b/tests/simulator/demo/others.py
deleted file mode 100644
index 0b87c0c..0000000
--- a/tests/simulator/demo/others.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2006, Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY 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, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import random
-
-from sugar.simulator import Bot
-
-for i in range(0, 8):
- bot = Bot()
-
- bot.wait(random.randint(10, 20))
- bot.join_activity('giraffes')
- bot.change_activity('giraffes')
-
- bot.start()
-
-for i in range(0, 6):
- bot = Bot()
-
- bot.wait(random.randint(10, 20))
- bot.join_activity('nekkhamma')
- bot.change_activity('nekkhamma')
-
- bot.start()
diff --git a/tests/simulator/demo/penelope.py b/tests/simulator/demo/penelope.py
deleted file mode 100644
index 60cc1fe..0000000
--- a/tests/simulator/demo/penelope.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (C) 2006, Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY 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, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-from sugar.simulator import Bot
-
-bot = Bot()
-bot.name = 'penelope'
-
-bot.share_chat('nekkhamma', 'Nekkhamma')
-
-bot.start()
diff --git a/tests/simulator/simulator b/tests/simulator/simulator
deleted file mode 100755
index 838d645..0000000
--- a/tests/simulator/simulator
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (C) 2006, Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY 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, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import os
-
-import gobject
-
-from sugar.presence import PresenceService
-
-PresenceService.start()
-
-base_path = os.path.abspath(os.path.dirname(__file__))
-
-stage_path = os.path.join(base_path, 'demo')
-for bot_file in os.listdir(stage_path):
- if bot_file.endswith('.py'):
- execfile(os.path.join(stage_path, bot_file))
-
-mainloop = gobject.MainLoop()
-mainloop.run()
diff --git a/tests/sketch/Makefile.am b/tests/sketch/Makefile.am
deleted file mode 100644
index d8e3c42..0000000
--- a/tests/sketch/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-sugardir = $(pkgdatadir)/activities/sketch
-sugar_PYTHON = \
- __init__.py \
- sketchactivity.py
-
-EXTRA_DIST = sketch.activity
diff --git a/tests/sketch/__init__.py b/tests/sketch/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tests/sketch/__init__.py
+++ /dev/null
diff --git a/tests/sketch/sketch.activity b/tests/sketch/sketch.activity
deleted file mode 100644
index 0722388..0000000
--- a/tests/sketch/sketch.activity
+++ /dev/null
@@ -1,6 +0,0 @@
-[Activity]
-name = Sketch
-id = org.laptop.Sketch
-icon = activity-sketch
-python_module = sketch.sketchactivity.SketchActivity
-show_launcher = yes
diff --git a/tests/sketch/sketchactivity.py b/tests/sketch/sketchactivity.py
deleted file mode 100644
index 97db0c4..0000000
--- a/tests/sketch/sketchactivity.py
+++ /dev/null
@@ -1,234 +0,0 @@
-# Copyright (C) 2006, Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY 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, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import gtk
-import gobject
-import os
-import logging
-
-from sugar.p2p import MostlyReliablePipe
-from sugar.p2p.Stream import Stream
-
-from sugar.presence import PresenceService
-from sugar.activity.Activity import Activity
-from sugar.chat.sketchpad import SketchPad
-from sugar.chat.sketchpad import Sketch
-from sugar.graphics.xocolor import XoColor
-from sugar import profile
-
-class NetworkController(gobject.GObject):
- __gsignals__ = {
- 'new-path':(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- ([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT])),
- }
-
- def __init__(self, parent, ps_owner):
- gobject.GObject.__init__(self)
- self._parent = parent
- self._parent.connect('buddy-joined', self._buddy_joined)
- self._parent.connect('buddy-left', self._buddy_left)
- self._stream = None
- self._stream_writer = None
- self._joined_buddies = {} # IP address -> buddy
- self._ps_owner = ps_owner
-
- def init_stream(self, service):
- self._stream = Stream.new_from_service(service)
- self._stream.set_data_listener(self._recv_message)
- self._stream_writer = self._stream.new_writer()
-
- def _recv_message(self, address, msg):
- # Ignore multicast messages from ourself
- if self._ps_owner and address == self._ps_owner.get_ip4_address():
- return
-
- # Ensure the message comes from somebody in this activity
- if not self._joined_buddies.has_key(address):
- logging.debug("Message from unjoined buddy.")
- return
-
- # Convert the points to an array and send to the sketchpad
- points = []
- msg = msg.strip()
- split_coords = msg.split(" ")
- for item in split_coords:
- x = 0
- y = 0
- try:
- (x, y) = item.split(",")
- x = float(x)
- y = float(y)
- except ValueError:
- continue
- if x < 0 or y < 0:
- continue
- points.append((x, y))
-
- buddy = self._joined_buddies[address]
- self.emit("new-path", buddy, points)
-
- def _buddy_joined(self, widget, activity, buddy, activity_type):
- activity_service = buddy.get_service_of_type(activity_type, activity)
- if not activity_service:
- logging.debug("Buddy Joined, but could not get activity service " \
- "of %s" % activity_type)
- return
-
- address = activity_service.get_source_address()
- port = activity_service.get_port()
- if not address or not port:
- logging.debug("Buddy Joined, but could not get address/port from" \
- " activity service %s" % activity_type)
- return
- if not self._joined_buddies.has_key(address):
- logging.debug("Buddy joined: %s (%s)" % (address, port))
- self._joined_buddies[address] = buddy
-
- def _buddy_left(self, widget, activity, buddy, activity_type):
- buddy_key = None
- for (key, value) in self._joined_buddies.items():
- if value == buddy:
- buddy_key = key
- break
- if buddy_key:
- del self._joined_buddies[buddy_key]
-
- def new_local_sketch(self, path):
- """ Receive an array of point tuples the local user created """
- cmd = ""
- # Convert points into the wire format
- for point in path:
- cmd = cmd + "%d,%d " % (point[0], point[1])
-
- # If there were no points, or we aren't in a shared activity yet,
- # don't send anything
- if not len(cmd) or not self._stream_writer:
- return
-
- # Send the points to other buddies
- self._stream_writer.write(cmd)
-
-def _html_to_rgb_color(colorstring):
- """ converts #RRGGBB to cairo-suitable floats"""
- colorstring = colorstring.strip()
- while colorstring[0] == '#':
- colorstring = colorstring[1:]
- r = int(colorstring[:2], 16)
- g = int(colorstring[2:4], 16)
- b = int(colorstring[4:6], 16)
- color = ((float(r) / 255.0), (float(g) / 255.0), (float(b) / 255.0))
- return color
-
-
-class SharedSketchPad(SketchPad.SketchPad):
- def __init__(self, net_controller, color):
- SketchPad.SketchPad.__init__(self, bgcolor=(1.0, 0.984313725, 0.560784314))
- self._net_controller = net_controller
- self._user_color = _html_to_rgb_color(color)
- self.set_color(self._user_color)
-
- # Receive notifications when our buddies send us new sketches
- self._net_controller.connect('new-path', self._new_buddy_path)
-
- self.connect('new-user-sketch', self._new_local_sketch_cb)
-
- def _new_buddy_path(self, net_controller, buddy, path):
- """ Called whenever a buddy on the mesh sends us a new sketch path """
- str_color = buddy.get_color()
- if not str_color:
- str_color = "#348798" # FIXME
- color = XoColor(str_color)
- stroke_color = _html_to_rgb_color(color.get_stroke_color())
- sketch = Sketch.Sketch(stroke_color)
- for item in path:
- sketch.add_point(item[0], item[1])
- self.add_sketch(sketch)
-
- def _new_local_sketch_cb(self, widget, sketch):
- """ Send the sketch the user just made to the network """
- self._net_controller.new_local_sketch(sketch.get_points())
-
-
-class SketchActivity(Activity):
- __gsignals__ = {
- 'buddy-joined':(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- ([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT])),
- 'buddy-left': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- ([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT]))
- }
-
- def __init__(self):
- Activity.__init__(self)
- self.connect('destroy', self._cleanup_cb)
-
- self.set_title("Sketch")
-
- self._ps = PresenceService.get_instance()
- self._ps_activity = None
- self._owner = self._ps.get_owner()
-
- self._net_controller = NetworkController(self, self._owner)
- self._sketchpad = SharedSketchPad(self._net_controller,
- profile.get_color().get_stroke_color())
- self.add(self._sketchpad)
- self.show_all()
-
- def get_ps(self):
- return self._ps
-
- def _cleanup_cb(self):
- del self._net_controller
-
- def share(self):
- Activity.share(self)
- self._net_controller.init_stream(self._service)
- self._ps.connect('activity-appeared', self._activity_appeared_cb)
-
- def join(self, activity_ps):
- Activity.join(self, activity_ps)
- self._net_controller.init_stream(self._service)
- self._ps.connect('activity-appeared', self._activity_appeared_cb)
- self._activity_appeared_cb(self._ps, activity_ps)
-
- def _activity_appeared_cb(self, ps, activity):
- # Only care about our own activity
- if activity.get_id() != self.get_id():
- return
-
- # If we already have found our shared activity, do nothing
- if self._ps_activity:
- return
-
- self._ps_activity = activity
-
- # Connect signals to the shared activity so we are notified when
- # buddies join and leave
- self._ps_activity.connect('buddy-joined', self._add_buddy)
- self._ps_activity.connect('buddy-left', self._remove_buddy)
-
- # Get the list of buddies already in this shared activity so we can
- # connect to them
- buddies = self._ps_activity.get_joined_buddies()
- for buddy in buddies:
- self._add_buddy(self._ps_activity, buddy)
-
- def _add_buddy(self, ps_activity, buddy):
- service_type = self._ps_activity
- self.emit('buddy-joined', ps_activity, buddy, self.get_default_type())
-
- def _remove_buddy(self, ps_activity, buddy):
- self.emit('buddy-left', ps_activity, buddy, self.get_default_type())
-