~chipaca/ubuntu-push/fix-1383867--trunk

« back to all changes in this revision

Viewing changes to client/service/postal_test.go

  • Committer: CI bot
  • Date: 2014-08-04 15:38:23 UTC
  • mfrom: (116.1.4 trunk)
  • Revision ID: ps-jenkins@lists.canonical.com-20140804153823-djffeana18j78bx1
* Add click hook to collect helpers data on install/update/etc and
  support to read the helper cached data, when available, and only
  refresh it when it changes.
* Include notification settings cleanup in the click install hook, and
  rename it to click-hook
* For the gsettings interface: Improve, add tests, make design-compliant.
* Query gsettings as to whether a notification should be presented.
* Cleanup and improve post/Post tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
        winStackBus  bus.Endpoint
142
142
        fakeLauncher *fakeHelperLauncher
143
143
        getTempDir   func(string) (string, error)
 
144
        oldIsBlisted func(*click.AppId) bool
 
145
        blacklisted  bool
144
146
}
145
147
 
146
148
type ualPostalSuite struct {
155
157
var _ = Suite(&trivialPostalSuite{})
156
158
 
157
159
func (ps *postalSuite) SetUpTest(c *C) {
 
160
        ps.oldIsBlisted = isBlacklisted
 
161
        isBlacklisted = func(*click.AppId) bool { return ps.blacklisted }
158
162
        ps.log = helpers.NewTestLogger(c, "debug")
159
163
        ps.bus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true))
160
164
        ps.notifBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true))
163
167
        ps.urlDispBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true))
164
168
        ps.winStackBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), []windowstack.WindowsInfo{})
165
169
        ps.fakeLauncher = &fakeHelperLauncher{ch: make(chan []byte)}
 
170
        ps.blacklisted = false
166
171
 
167
172
        ps.getTempDir = launch_helper.GetTempDir
168
173
        d := c.MkDir()
173
178
}
174
179
 
175
180
func (ps *postalSuite) TearDownTest(c *C) {
 
181
        isBlacklisted = ps.oldIsBlisted
176
182
        launch_helper.GetTempDir = ps.getTempDir
177
183
}
178
184
 
779
785
                c.Check(err, Equals, s.err, Commentf("iter %d", i))
780
786
        }
781
787
}
 
788
 
 
789
func (ps *postalSuite) TestBlacklisted(c *C) {
 
790
        svc := ps.replaceBuses(NewPostalService(nil, ps.log))
 
791
        svc.Start()
 
792
        ps.blacklisted = false
 
793
 
 
794
        emb := &launch_helper.EmblemCounter{Count: 2, Visible: true}
 
795
        card := &launch_helper.Card{Icon: "icon-value", Summary: "summary-value", Persist: true}
 
796
        output := &launch_helper.HelperOutput{Notification: &launch_helper.Notification{Card: card}}
 
797
        embOut := &launch_helper.HelperOutput{Notification: &launch_helper.Notification{EmblemCounter: emb}}
 
798
        app := clickhelp.MustParseAppId("com.example.app_app_1.0")
 
799
        // sanity check: things are presented as normal if blacklist == false
 
800
        ps.blacklisted = false
 
801
        c.Check(svc.messageHandler(app, "0", output), Equals, true)
 
802
        c.Check(svc.messageHandler(app, "1", embOut), Equals, true)
 
803
        ps.blacklisted = true
 
804
        // and regular notifications (but not emblem counters) are supprsessed if blacklisted.
 
805
        c.Check(svc.messageHandler(app, "2", output), Equals, false)
 
806
        c.Check(svc.messageHandler(app, "3", embOut), Equals, true)
 
807
}