Skip to content

Commit

Permalink
Test typing in Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
lewtds committed Apr 11, 2015
1 parent 7b596a7 commit b0cfd04
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 1 deletion.
20 changes: 20 additions & 0 deletions tests/facebook-comment.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Bogo Facebook Comments Test</title>
</head>
<body>
<div class="fb-comments" data-href="http://developers.facebook.com/docs/plugins/comments/" data-width="600px" data-numposts="1" data-colorscheme="light"></div>

<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "http://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3&appId=409391635895497";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

</body>
</html>
75 changes: 74 additions & 1 deletion tests/gui.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# -*- coding: utf-8 -*-

from dogtail.procedural import *
from dogtail import tree
from subprocess import call, Popen
import os
import signal
import time
import unittest
from gi.repository import Gtk, Gdk
import SimpleHTTPServer
import SocketServer
import threading



keysequence = open(os.path.join(os.path.dirname(__file__), 'keysequence')).read().strip()
Expand Down Expand Up @@ -156,6 +161,74 @@ def testTypeInTextTool(self):

clipboard_text = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD).wait_for_text()
self.assertEqual(clipboard_text, expected)



@unittest.skipIf(not hasCommand('firefox'), 'firefox not available')
class TestFirefox(BogoTestCase):
command = 'make run GTK=2 CMD=firefox'
appName = 'Firefox'
httpd = None

@classmethod
def setUpClass(cls):
def serve():
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
cls.httpd = SocketServer.TCPServer(("", PORT), Handler)
cls.httpd.serve_forever()

threading.Thread(target=serve).start()

cls.pid = run(cls.command, appName=cls.appName)
cls.app = tree.root.application('Firefox')
time.sleep(2)

@classmethod
def tearDownClass(cls):
cls.httpd.shutdown()
os.kill(cls.pid, signal.SIGTERM)

def setUp(self):
pass

def tearDown(self):
pass

def goToAddress(self, addr):
address_bar = self.app.child(roleName='entry',
name='Search or enter address')
address_bar.text = addr
address_bar.keyCombo('Return')
time.sleep(5)

def testTypeInVanillaTextArea(self):
self.goToAddress('http://localhost:8000/tests/text-area.html')
page = self.app.child(roleName='document frame',
name='Bogo Text Area Test')
entry = page.child(name='test area', roleName='entry')
entry.click()

self.typeIn()

self.assertEqual(entry.text, expected)

@unittest.expectedFailure
def testTypeInFacebookComment(self):
self.goToAddress('http://localhost:8000/tests/facebook-comment.html')
page = self.app.child(roleName='document frame',
name='Bogo Facebook Comments Test')

fb = page.child(roleName='document frame',
name='Facebook Social Plugin')

commentDiv = fb[0][0][0][0][1][1][0][0]
commentDiv.click()

self.typeIn()

entry = page.child(roleName='combo box')[0][0]
self.assertEqual(entry.text, expected)


if __name__ == '__main__':
unittest.main()
10 changes: 10 additions & 0 deletions tests/text-area.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Bogo Text Area Test</title>
</head>
<body>
<textarea title="test area" cols="30" id="" name="" rows="10"></textarea>
</body>
</html>

0 comments on commit b0cfd04

Please sign in to comment.