~gary-lasker/software-center/handle-trans-cancel-lp1027209-for-5.2

« back to all changes in this revision

Viewing changes to test/gtk3/test_webkit.py

  • Committer: Gary Lasker
  • Date: 2012-09-06 19:46:40 UTC
  • mfrom: (3075.1.2 auto-fill-email-5.2)
  • Revision ID: gary.lasker@canonical.com-20120906194640-jns070f286urs5di
* lp:~mvo/software-center/auto-fill-email-for-login:
  - allow auto-fill of the email in login.ubuntu.com if
    we have it (LP: #1042279)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import unittest
2
2
 
3
 
from gi.repository import Soup, WebKit
 
3
from gi.repository import (
 
4
    GObject,
 
5
    Soup,
 
6
    WebKit,
 
7
    )
4
8
 
5
9
from mock import patch
6
10
 
36
40
        self.assertTrue(
37
41
            canary in settings.get_property("user-agent"))
38
42
        
39
 
        
 
43
    def test_auto_fill_in_email(self):
 
44
        def _load_status_changed(view, status):
 
45
            if view.get_property("load-status") == WebKit.LoadStatus.FINISHED:
 
46
                loop.quit()
 
47
        loop =  GObject.MainLoop(GObject.main_context_default())       
 
48
        webview = SoftwareCenterWebView()
 
49
        email = "foo@bar"
 
50
        webview.set_auto_insert_email(email)
 
51
        with patch.object(webview, "execute_script") as mock_execute_js:
 
52
            webview.connect("notify::load-status", _load_status_changed)
 
53
            webview.load_uri("https://login.ubuntu.com")
 
54
            loop.run()
 
55
            mock_execute_js.assert_called()
 
56
            mock_execute_js.assert_called_with(
 
57
                SoftwareCenterWebView.AUTO_FILL_EMAIL_JS % email)
 
58
 
40
59
 
41
60
if __name__ == "__main__":
42
61
    unittest.main()