added test for per SSID URL in GConf
authorFredrik Wendt <fredrik@wendt.se>
Fri, 17 Dec 2010 20:21:07 +0000 (20:21 +0000)
committerFredrik Wendt <fredrik@wendt.se>
Fri, 17 Dec 2010 20:21:07 +0000 (20:21 +0000)
package/test/unit/daemon/daemon_test.py

index 2f45204..21aac9b 100644 (file)
@@ -5,17 +5,28 @@ from wifi_assistant.settings.network_setting import NetworkSetting
 import unittest
 from unit.pie import *
 
 import unittest
 from unit.pie import *
 
-url_to_open = 'http://wifi-assistant.garage.maemo.org'
+default_url_to_open = 'http://wifi-assistant.garage.maemo.org'
 default_browser_name = "default"
 default_browser_name = "default"
-default_browser_options = {'url':url_to_open}
+default_browser_options = {'url':default_url_to_open}
 default_settings = NetworkSetting()
 default_settings.setNameOfBrowserToLaunch(default_browser_name)
 default_settings.setBrowserOptions(default_browser_options)
 default_settings = NetworkSetting()
 default_settings.setNameOfBrowserToLaunch(default_browser_name)
 default_settings.setBrowserOptions(default_browser_options)
+
 ssid = 'A Network Name'
 settings_without_options = NetworkSetting()
 settings_without_options.setNetworkName(ssid)
 settings_without_options.setLaunchingOfBrowserEnabled(True)
 
 ssid = 'A Network Name'
 settings_without_options = NetworkSetting()
 settings_without_options.setNetworkName(ssid)
 settings_without_options.setLaunchingOfBrowserEnabled(True)
 
+second_ssid = 'Another Network SSID'
+second_url = 'http://some.specific.site/'
+second_browser_name = 'special browser'
+second_settings = NetworkSetting()
+second_settings.setNetworkName(second_ssid)
+second_settings.setNameOfBrowserToLaunch(second_browser_name)
+second_settings.setLaunchingOfBrowserEnabled(True)
+second_browser_options = {'url': second_url}
+second_settings.setBrowserOptions(second_browser_options)
+
 class DaemonTest(unittest.TestCase):
 
     def setUp(self):
 class DaemonTest(unittest.TestCase):
 
     def setUp(self):
@@ -41,6 +52,7 @@ class DaemonTest(unittest.TestCase):
         
         
     def test_withANewNetwork_whenUserClicksNo_browserIsNotLaunched(self):
         
         
     def test_withANewNetwork_whenUserClicksNo_browserIsNotLaunched(self):
+        # GIVEN
         self._createTesteeWithPopupClickingNo()
         given(self.network_settings).get(ssid).willReturn(None)
 
         self._createTesteeWithPopupClickingNo()
         given(self.network_settings).get(ssid).willReturn(None)
 
@@ -53,6 +65,7 @@ class DaemonTest(unittest.TestCase):
         
     
     def test_popupIsNotOpenedIfPopupIsDisabledInApplicationSettings(self):
         
     
     def test_popupIsNotOpenedIfPopupIsDisabledInApplicationSettings(self):
+        # GIVEN
         given(self.application_settings).getUsePopup().willReturn(False)
         self.testee = Daemon(self.launcher, self.application_settings, self.network_settings, self.parent_window)
         
         given(self.application_settings).getUsePopup().willReturn(False)
         self.testee = Daemon(self.launcher, self.application_settings, self.network_settings, self.parent_window)
         
@@ -67,7 +80,6 @@ class DaemonTest(unittest.TestCase):
         given(self.network_settings).get(ssid).willReturn(settings_without_options)
         given(self.network_settings).getDefaultSettings().willReturn(default_settings)
         given(self.application_settings).getUsePopup().willReturn(True)
         given(self.network_settings).get(ssid).willReturn(settings_without_options)
         given(self.network_settings).getDefaultSettings().willReturn(default_settings)
         given(self.application_settings).getUsePopup().willReturn(True)
-        #self.testee = Daemon(self.launcher, self.application_settings, self.network_settings, self.parent_window)
         self.testee = self._createTestee()
         
         self._replayMocks()
         self.testee = self._createTestee()
         
         self._replayMocks()
@@ -76,6 +88,17 @@ class DaemonTest(unittest.TestCase):
         verify(self.launcher, once()).launchBrowser(default_browser_name, default_browser_options)
     
     
         verify(self.launcher, once()).launchBrowser(default_browser_name, default_browser_options)
     
     
+    def test_browserIsLaunchedWithSsidSpecificUrl_insteadOfDefaultUrl(self):
+        given(self.network_settings).get(second_ssid).willReturn(second_settings)
+        given(self.application_settings).getUsePopup().willReturn(True)
+        self.testee = self._createTestee()
+        
+        self._replayMocks()
+        self.testee.connectionEstablished(second_ssid)
+        
+        verify(self.launcher, once()).launchBrowser(second_browser_name, second_browser_options)
+    
+    
     def test_daemon_start_registersListenerWithApplicationSettings(self):
         given(self.application_settings).getUsePopup().willReturn(True)
         self.testee = self._createTestee()
     def test_daemon_start_registersListenerWithApplicationSettings(self):
         given(self.application_settings).getUsePopup().willReturn(True)
         self.testee = self._createTestee()