~mvo/software-center/qml-banners2

« back to all changes in this revision

Viewing changes to test/gtk3/test_appdetailsview.py

  • Committer: Kiwinote
  • Date: 2012-03-15 22:36:31 UTC
  • mfrom: (2867 trunk)
  • mto: This revision was merged to the branch mainline in revision 2881.
  • Revision ID: kiwinote@gmail.com-20120315223631-lvea6t5sydpkkqni
mergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
        do_events()
52
52
        self.assertTrue(self.view.videoplayer.get_property("visible"))
53
53
    
54
 
    def test_page_pkgstatusbar(self):
 
54
    def test_page_pkgstates(self):
55
55
        # show app 
56
56
        app = Application("", "abiword")
57
57
        self.view.show_app(app)
68
68
        mock_details._error_not_found = "error not found"
69
69
        mock_details.price = "1.00"
70
70
        mock_details.pkgname = "abiword"
71
 
        mock_details.error = ""
 
71
        mock_details.error = "error-text"
72
72
        self.view.app_details = mock_details
73
73
 
74
74
        # the states and what labels we expect in the pkgstatusbar
79
79
            PkgStates.NEEDS_PURCHASE : ('US$ 1.00', u'Buy\u2026'),
80
80
            PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED : ('Purchased on 2011-11-20', 'Install'),
81
81
        }
 
82
        # this describes if a button is visible or invisible
 
83
        button_invisible = [ PkgStates.ERROR,
 
84
                             PkgStates.NOT_FOUND,
 
85
                             PkgStates.INSTALLING_PURCHASED,
 
86
                             PkgStates.PURCHASED_BUT_NOT_AVAILABLE_FOR_SERIES,
 
87
                             PkgStates.UNKNOWN,
 
88
                           ]
82
89
 
83
 
        # show a app through the various states
 
90
        # show a app through the various states and test if the right ui
 
91
        # elements are visible and have the right text
84
92
        for var in vars(PkgStates):
85
 
            # FIXME: this just ensures we are not crashing, also
86
 
            # add functional tests to ensure on error we show
87
 
            # the right info etc
88
93
            state = getattr(PkgStates, var)
89
94
            mock_details.pkg_state = state
90
95
            # reset app to ensure its shown again
91
96
            self.view.app = None
92
97
            # show it
93
98
            self.view.show_app(mock_app)
 
99
            #do_events()
 
100
            # check button label
94
101
            if state in pkg_states_to_labels:
95
102
                label, button_label = pkg_states_to_labels[state]
96
103
                self.assertEqual(
99
106
                self.assertEqual(
100
107
                    self.view.pkg_statusbar.get_button_label().decode("utf-8"),
101
108
                    button_label)
 
109
            # check if button should be there or not
 
110
            if state in button_invisible:
 
111
                self.assertFalse(
 
112
                    self.view.pkg_statusbar.button.get_property("visible"),
 
113
                    "button visible error for state %s" % state)
 
114
            else:
 
115
                self.assertTrue(
 
116
                    self.view.pkg_statusbar.button.get_property("visible"),
 
117
                    "button visible error for state %s" % state)
 
118
            # regression test for #955005
 
119
            if state == PkgStates.NOT_FOUND:
 
120
                self.assertFalse(self.view.review_stats.get_property("visible"))
 
121
                self.assertFalse(self.view.reviews.get_property("visible"))
102
122
 
103
123
    def test_app_icon_loading(self):
104
124
        # get icon
565
585
 
566
586
 
567
587
if __name__ == "__main__":
568
 
    #import logging
569
 
    #logging.basicConfig(level=logging.DEBUG)
 
588
    import logging
 
589
    logging.basicConfig(level=logging.DEBUG)
570
590
    unittest.main()