def testProfileChange(self): self.topics = [Topic('onProfileChange')] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq': 100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
def testStereoModeChange(self): self.topics = [Topic('onStereoModeChange')] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq': 100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
def testOnWindowClose(self): self.topics = [Topic('onWindowClose', 'E1')] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq': 100}) flexmock(settings, getClosewindowids={10001: 'E1'}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
def testOnWindowOpen(self): self.topics = [Topic('onWindowOpen', 'E1')] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq': 100}) flexmock(settings, getOpenwindowids={10001: 'E1'}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
def testLoopIdle(self): self.topics = [Topic('onIdle', 'E1'), Topic('onIdle', 'E2')] for topic in self.topics: self.subscriber.addTopic(topic) self.dispatcher.addSubscriber(self.subscriber) idleSettings = {'E1': 3, 'E2': 5} settings = Settings() flexmock(settings, getIdleTimes=idleSettings) flexmock(settings, general={'LoopFreq': 100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(7) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
def testProfileChange(self): self.topics = [Topic("onProfileChange")] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={"LoopFreq": 100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
def testProfileChange(self): self.topics = [Topic('onProfileChange')] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq':100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
def testOnWindowClose(self): self.topics = [Topic("onWindowClose", "E1")] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={"LoopFreq": 100}) flexmock(settings, getClosewindowids={10001: "E1"}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
def testOnWindowClose(self): self.topics = [Topic('onWindowClose','E1' )] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq':100}) flexmock(settings, getClosewindowids={10001:'E1'}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
def testLoopIdle(self): self.topics = [Topic("onIdle", "E1"), Topic("onIdle", "E2")] for topic in self.topics: self.subscriber.addTopic(topic) self.dispatcher.addSubscriber(self.subscriber) idleSettings = {"E1": 3, "E2": 5} settings = Settings() flexmock(settings, getIdleTimes=idleSettings) flexmock(settings, general={"LoopFreq": 100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=2, timeout=7) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
def testLoopIdle(self): self.topics = [Topic('onIdle','E1'), Topic('onIdle', 'E2')] for topic in self.topics: self.subscriber.addTopic(topic) self.dispatcher.addSubscriber(self.subscriber) idleSettings = {'E1':3, 'E2':5} settings = Settings() flexmock(settings, getIdleTimes=idleSettings) flexmock(settings, general={'LoopFreq':100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(7) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
class testLoop(object): def __init__(self): self.publisher = None self.dispatcher = None self.subscriber = None self.globalidletime = None self.starttime = None self.topics = None def getGlobalIdleTime(self): if self.globalidletime is None: self.starttime = time.time() self.globalidletime = 0 return 0 else: self.globalidletime = int(time.time() - self.starttime) return self.globalidletime def getStereoMode(self): if self.getGlobalIdleTime() < 2: return 'off' else: return 'split_vertical' def getCurrentWindowId(self): git = self.getGlobalIdleTime() if git < 2: return 10000 elif 2 <= git < 4: return 10001 else: return 10002 def getProfileString(self): if self.getGlobalIdleTime() < 2: return 'Bob' else: return 'Mary' def setup(self): flexmock(loop.xbmc, getGlobalIdleTime=self.getGlobalIdleTime) flexmock(loop.xbmc, sleep=sleep) flexmock(loop, getStereoscopicMode=self.getStereoMode) flexmock(loop, getProfileString=self.getProfileString) flexmock(loop.xbmc.Player, isPlaying=False) flexmock(loop.xbmcgui, getCurrentWindowId=self.getCurrentWindowId) self.dispatcher = Dispatcher() self.subscriber = testSubscriber() def teardown(self): self.publisher.abort() self.dispatcher.abort() del self.publisher del self.dispatcher def testLoopIdle(self): self.topics = [Topic('onIdle', 'E1'), Topic('onIdle', 'E2')] for topic in self.topics: self.subscriber.addTopic(topic) self.dispatcher.addSubscriber(self.subscriber) idleSettings = {'E1': 3, 'E2': 5} settings = Settings() flexmock(settings, getIdleTimes=idleSettings) flexmock(settings, general={'LoopFreq': 100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(7) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics def testStereoModeChange(self): self.topics = [Topic('onStereoModeChange')] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq': 100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics def testOnWindowOpen(self): self.topics = [Topic('onWindowOpen', 'E1')] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq': 100}) flexmock(settings, getOpenwindowids={10001: 'E1'}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics def testOnWindowClose(self): self.topics = [Topic('onWindowClose', 'E1')] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq': 100}) flexmock(settings, getClosewindowids={10001: 'E1'}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics def testProfileChange(self): self.topics = [Topic('onProfileChange')] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq': 100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
class testLoop(object): def __init__(self): self.publisher = None self.dispatcher = None self.subscriber = None self.globalidletime = None self.starttime = None self.topics = None def getGlobalIdleTime(self): if self.globalidletime is None: self.starttime = time.time() self.globalidletime = 0 return 0 else: self.globalidletime = int(time.time() - self.starttime) return self.globalidletime def getStereoMode(self): if self.getGlobalIdleTime() < 2: return "off" else: return "split_vertical" def getCurrentWindowId(self): git = self.getGlobalIdleTime() if git < 2: return 10000 elif 2 <= git < 4: return 10001 else: return 10002 def getProfileString(self): if self.getGlobalIdleTime() < 2: return "Bob" else: return "Mary" def setup(self): flexmock(loop.xbmc, getGlobalIdleTime=self.getGlobalIdleTime) flexmock(loop.xbmc, sleep=sleep) flexmock(loop, getStereoscopicMode=self.getStereoMode) flexmock(loop, getProfileString=self.getProfileString) flexmock(loop.xbmc.Player, isPlaying=False) flexmock(loop.xbmcgui, getCurrentWindowId=self.getCurrentWindowId) self.dispatcher = Dispatcher() self.subscriber = MockSubscriber() def teardown(self): self.publisher.abort() self.dispatcher.abort() del self.publisher del self.dispatcher def testLoopIdle(self): self.topics = [Topic("onIdle", "E1"), Topic("onIdle", "E2")] for topic in self.topics: self.subscriber.addTopic(topic) self.dispatcher.addSubscriber(self.subscriber) idleSettings = {"E1": 3, "E2": 5} settings = Settings() flexmock(settings, getIdleTimes=idleSettings) flexmock(settings, general={"LoopFreq": 100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=2, timeout=7) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics def testStereoModeChange(self): self.topics = [Topic("onStereoModeChange")] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={"LoopFreq": 100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics def testOnWindowOpen(self): self.topics = [Topic("onWindowOpen", "E1")] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={"LoopFreq": 100}) flexmock(settings, getOpenwindowids={10001: "E1"}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics def testOnWindowClose(self): self.topics = [Topic("onWindowClose", "E1")] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={"LoopFreq": 100}) flexmock(settings, getClosewindowids={10001: "E1"}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics def testProfileChange(self): self.topics = [Topic("onProfileChange")] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={"LoopFreq": 100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
class testLoop(object): def __init__(self): self.publisher=None self.dispatcher=None self.subscriber=None self.globalidletime=None self.starttime = None self.topics = None def getGlobalIdleTime(self): if self.globalidletime is None: self.starttime = time.time() self.globalidletime = 0 return 0 else: self.globalidletime = int(time.time()-self.starttime) return self.globalidletime def getStereoMode(self): if self.getGlobalIdleTime() < 2: return 'off' else: return 'split_vertical' def getCurrentWindowId(self): git = self.getGlobalIdleTime() if git <2: return 10000 elif 2 <= git < 4: return 10001 else: return 10002 def getProfileString(self): if self.getGlobalIdleTime() < 2: return 'Bob' else: return 'Mary' def setup(self): flexmock(loop.xbmc, getGlobalIdleTime=self.getGlobalIdleTime) flexmock(loop.xbmc, sleep=sleep) flexmock(loop, getStereoscopicMode=self.getStereoMode) flexmock(loop, getProfileString=self.getProfileString) flexmock(loop.xbmc.Player, isPlaying=False) flexmock(loop.xbmcgui, getCurrentWindowId=self.getCurrentWindowId) self.dispatcher = Dispatcher() self.subscriber = testSubscriber() def teardown(self): self.publisher.abort() self.dispatcher.abort() del self.publisher del self.dispatcher def testLoopIdle(self): self.topics = [Topic('onIdle','E1'), Topic('onIdle', 'E2')] for topic in self.topics: self.subscriber.addTopic(topic) self.dispatcher.addSubscriber(self.subscriber) idleSettings = {'E1':3, 'E2':5} settings = Settings() flexmock(settings, getIdleTimes=idleSettings) flexmock(settings, general={'LoopFreq':100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(7) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics def testStereoModeChange(self): self.topics = [Topic('onStereoModeChange')] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq':100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics def testOnWindowOpen(self): self.topics = [Topic('onWindowOpen','E1' )] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq':100}) flexmock(settings, getOpenwindowids={10001:'E1'}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics def testOnWindowClose(self): self.topics = [Topic('onWindowClose','E1' )] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq':100}) flexmock(settings, getClosewindowids={10001:'E1'}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics def testProfileChange(self): self.topics = [Topic('onProfileChange')] self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) settings = Settings() flexmock(settings, general={'LoopFreq':100}) self.publisher = LoopPublisher(self.dispatcher, settings) self.dispatcher.start() self.publisher.start() time.sleep(5) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics