Commits

Yuya Nishihara committed ad88c88

repoagent_test: add basic tests for workingBranchChanged signal

  • Participants
  • Parent commits 115718c

Comments (0)

Files changed (2)

File tests/qt_repoagent_test.py

         repo = thgrepo.repository(ui, self.hg.path)
         self.agent = agent = thgrepo.RepoAgent(repo)
         self.repositoryChanged = mock.Mock()
+        self.workingBranchChanged = mock.Mock()
         agent.repositoryChanged.connect(self.repositoryChanged)
+        agent.workingBranchChanged.connect(self.workingBranchChanged)
         agent.startMonitoringIfEnabled()
 
     def tearDown(self):
 
     def wait_changed(self, flags, timeout=5000):
         self.repositoryChanged.reset_mock()
+        self.workingBranchChanged.reset_mock()
         loop = QEventLoop()
         self.agent.repositoryChanged.connect(loop.quit)
+        self.agent.workingBranchChanged.connect(loop.quit)
         QTimer.singleShot(timeout, loop.quit)
         loop.exec_()
         if flags & (thgrepo.LogChanged | thgrepo.WorkingParentChanged):
             self.repositoryChanged.assert_called_once_with()
+        if flags & thgrepo.WorkingBranchChanged:
+            self.workingBranchChanged.assert_called_once_with()
         self.assertFalse(self.agent.isBusy(),
                          'repositoryChanged emitted while busy')
 
         self.agent.runCommandSequence([['update', '0'], ['root']])
         self.wait_changed(thgrepo.WorkingParentChanged)
 
+    def test_branch_changed(self):
+        # TODO: it should be notified without dirstate change, "udpate -C"
+        self.agent.runCommandSequence([['update', '-C'],
+                                       ['branch', 'foo']])
+        self.wait_changed(thgrepo.WorkingBranchChanged)
+
+    def test_branch_and_parent_changed(self):
+        self.agent.runCommandSequence([['update', '0'],
+                                       ['branch', 'foo']])
+        # TODO: WorkingBranchChanged should be included
+        self.wait_changed(thgrepo.WorkingParentChanged)
+
     def test_invalidate_on_dirstate_changed(self):
         repo = self.agent.rawRepo()
         self.assertEqual(set(['foo']), set(repo.dirstate))  # preload cache

File tortoisehg/hgqt/thgrepo.py

 # flags describing changes that could occur in repository
 LogChanged = 0x1
 WorkingParentChanged = 0x2
+WorkingBranchChanged = 0x4
 
 
 class _LockStillHeld(Exception):