Exemple #1
0
func (*AccountSuite) Test_account_createSubmenu_setsTheCheckboxesCorrectly(c *C) {
	i18n.InitLocalization(&accountMockGlib{})
	g = Graphics{gtk: &accountMockGtk{}, glib: &accountDirectGlibIdleAddMock{}}

	conf := &config.Account{ConnectAutomatically: true, AlwaysEncrypt: true}
	sess := &accountMockSession{config: conf}
	a := &account{session: sess}

	menu := a.createSubmenu()
	createdMenu := menu.(*accountMockMenu)
	c.Assert(createdMenu.menuItems[7].(*accountMockCheckMenuItem).active, Equals, true)
	c.Assert(createdMenu.menuItems[8].(*accountMockCheckMenuItem).active, Equals, true)

	conf.AlwaysEncrypt = false
	menu = a.createSubmenu()
	createdMenu = menu.(*accountMockMenu)
	c.Assert(createdMenu.menuItems[7].(*accountMockCheckMenuItem).active, Equals, true)
	c.Assert(createdMenu.menuItems[8].(*accountMockCheckMenuItem).active, Equals, false)

	conf.ConnectAutomatically = false
	menu = a.createSubmenu()
	createdMenu = menu.(*accountMockMenu)
	c.Assert(createdMenu.menuItems[7].(*accountMockCheckMenuItem).active, Equals, false)
	c.Assert(createdMenu.menuItems[8].(*accountMockCheckMenuItem).active, Equals, false)

	conf.AlwaysEncrypt = true
	menu = a.createSubmenu()
	createdMenu = menu.(*accountMockMenu)
	c.Assert(createdMenu.menuItems[7].(*accountMockCheckMenuItem).active, Equals, false)
	c.Assert(createdMenu.menuItems[8].(*accountMockCheckMenuItem).active, Equals, true)
}
Exemple #2
0
func (*AccountSuite) Test_account_createSubmenu_createsTheGeneralStructure(c *C) {
	i18n.InitLocalization(&accountMockGlib{})
	g = Graphics{gtk: &accountMockGtk{}, glib: &accountDirectGlibIdleAddMock{}}

	sess := &accountMockSession{config: &config.Account{}}
	a := &account{session: sess}
	menu := a.createSubmenu()
	c.Assert(menu, Not(IsNil))

	createdMenu := menu.(*accountMockMenu)

	c.Assert(createdMenu.menuItems, Not(IsNil))
	c.Assert(createdMenu.menuItems[0].(*accountMockMenuItem).mnemonic, Equals, "[localized] _Connect")
	c.Assert(createdMenu.menuItems[1].(*accountMockMenuItem).mnemonic, Equals, "[localized] _Disconnect")

	_, ok := createdMenu.menuItems[2].(*accountMockSeparatorMenuItem)
	c.Assert(ok, Equals, true)

	c.Assert(createdMenu.menuItems[4].(*accountMockMenuItem).mnemonic, Equals, "[localized] _Edit...")
	c.Assert(createdMenu.menuItems[5].(*accountMockMenuItem).mnemonic, Equals, "[localized] _Remove")

	_, ok = createdMenu.menuItems[6].(*accountMockSeparatorMenuItem)
	c.Assert(ok, Equals, true)

	c.Assert(createdMenu.menuItems[7].(*accountMockCheckMenuItem).mnemonic, Equals, "[localized] Connect _Automatically")
	c.Assert(createdMenu.menuItems[8].(*accountMockCheckMenuItem).mnemonic, Equals, "[localized] Always Encrypt Conversation")
}
Exemple #3
0
func runClient() {
	g := gui.CreateGraphics(
		gtka.Real,
		gliba.Real,
		gdka.Real,
		pangoa.Real,
	)

	i18n.InitLocalization(gliba.Real)
	settings.InitSettings(gliba.Real)

	gui.NewGTK(coyimVersion, session.Factory, xmpp.DialerFactory, g).Loop()
}
Exemple #4
0
func (*AccountSuite) Test_account_createSubmenu_setsConnectAndDisconnectSensitivity(c *C) {
	i18n.InitLocalization(&accountMockGlib{})
	g = Graphics{gtk: &accountMockGtk{}, glib: &accountDirectGlibIdleAddMock{}}

	sess := &accountMockSession{isDisconnected: true, config: &config.Account{}}
	a := &account{session: sess}

	menu := a.createSubmenu()
	createdMenu := menu.(*accountMockMenu)
	c.Assert(createdMenu.menuItems[0].(*accountMockMenuItem).sensitive, Equals, true)
	c.Assert(createdMenu.menuItems[1].(*accountMockMenuItem).sensitive, Equals, false)

	sess.isDisconnected = false
	menu = a.createSubmenu()
	createdMenu = menu.(*accountMockMenu)
	c.Assert(createdMenu.menuItems[0].(*accountMockMenuItem).sensitive, Equals, false)
	c.Assert(createdMenu.menuItems[1].(*accountMockMenuItem).sensitive, Equals, true)
}
Exemple #5
0
func (*AccountSuite) Test_account_createSubmenu_willWatchForThingsToChangeTheDisconnectSensitivity(c *C) {
	i18n.InitLocalization(&accountMockGlib{})
	g = Graphics{gtk: &accountMockGtk{}, glib: &accountDirectGlibIdleAddMock{}}

	sess := &accountMockSession{isDisconnected: true, config: &config.Account{}}
	a := &account{session: sess}

	menu := a.createSubmenu()
	disconnectItem := menu.(*accountMockMenu).menuItems[1].(*accountMockMenuItem)

	c.Assert(disconnectItem.sensitive, Equals, false)

	sess.isDisconnected = false
	for _, cc := range sess.events {
		cc <- events.Event{
			Type: events.Connecting,
		}
	}

	waitFor(c, func() bool { return disconnectItem.sensitive })

	sess.isDisconnected = false
	for _, cc := range sess.events {
		cc <- events.Event{
			Type: events.Connected,
		}
	}

	waitFor(c, func() bool { return disconnectItem.sensitive })

	sess.isDisconnected = true
	for _, cc := range sess.events {
		cc <- events.Event{
			Type: events.Disconnected,
		}
	}

	waitFor(c, func() bool { return !disconnectItem.sensitive })
}
Exemple #6
0
func (*AccountSuite) Test_account_createSubmenu_setsActivationCorrectly(c *C) {
	i18n.InitLocalization(&accountMockGlib{})
	g = Graphics{gtk: &accountMockGtk{}, glib: &accountDirectGlibIdleAddMock{}}

	sess := &accountMockSession{config: &config.Account{}}
	a := &account{session: sess}

	menu := a.createSubmenu()
	createdMenu := menu.(*accountMockMenu)

	// We can't really check that these things are set to the correct functions, just that they are set
	// It might be possible to try invoking them and see that they do the right things, at some point
	// For now, too much bother.

	c.Assert(createdMenu.menuItems[0].(*accountMockMenuItem).onActivate, Not(IsNil))
	c.Assert(createdMenu.menuItems[1].(*accountMockMenuItem).onActivate, Not(IsNil))

	c.Assert(createdMenu.menuItems[4].(*accountMockMenuItem).onActivate, Not(IsNil))
	c.Assert(createdMenu.menuItems[5].(*accountMockMenuItem).onActivate, Not(IsNil))

	c.Assert(createdMenu.menuItems[7].(*accountMockCheckMenuItem).onActivate, Not(IsNil))
	c.Assert(createdMenu.menuItems[8].(*accountMockCheckMenuItem).onActivate, Not(IsNil))
}
Exemple #7
0
func (s *GUIXmppSuite) Test_createStatusMessage_createsStatusMessages(c *C) {
	i18n.InitLocalization(&glib_mock.Mock{})

	c.Assert(createStatusMessage("Foo", "", "", false), Equals, "Foo is now Available")

	c.Assert(createStatusMessage("Foo", "", "", true), Equals, "Foo is now Offline")
	c.Assert(createStatusMessage("Foo", "", "something happened", true), Equals, "Foo is now Offline (something happened)")
	c.Assert(createStatusMessage("Foo", "xa", "something happened", true), Equals, "Foo is now Offline (Not Available: something happened)")
	c.Assert(createStatusMessage("Foo", "xa", "", true), Equals, "Foo is now Offline (Not Available)")

	c.Assert(createStatusMessage("Foo", "xa", "something happened", false), Equals, "Foo is now Not Available (something happened)")

	c.Assert(createStatusMessage("Foo2", "dnd", "", false), Equals, "Foo2 is now Busy")
	c.Assert(createStatusMessage("Foo2", "dnd", "some stuff", false), Equals, "Foo2 is now Busy (some stuff)")

	c.Assert(createStatusMessage("Foo2", "chat", "", false), Equals, "Foo2 is now Free for Chat")
	c.Assert(createStatusMessage("Foo2", "chat", "really!", false), Equals, "Foo2 is now Free for Chat (really!)")

	c.Assert(createStatusMessage("Foo3", "away", "", false), Equals, "Foo3 is now Away")
	c.Assert(createStatusMessage("Foo3", "away", "wut", false), Equals, "Foo3 is now Away (wut)")

	c.Assert(createStatusMessage("Foo4", "invisible", "", false), Equals, "Foo4 is now Invisible")
	c.Assert(createStatusMessage("Foo4", "invisible", "wut", false), Equals, "Foo4 is now Invisible (wut)")
}
Exemple #8
0
func (*AccountSuite) Test_account_createSubmenu_setsActivationCorrectly(c *C) {
	i18n.InitLocalization(&accountMockGlib{})
	g = Graphics{gtk: &accountMockGtk{}, glib: &accountDirectGlibIdleAddMock{}}

	sess := &accountMockSession{config: &config.Account{}}
	a := &account{session: sess}

	menu := a.createSubmenu()
	createdMenu := menu.(*accountMockMenu)

	// We can't really check that these things are set to the correct functions, just that they are set
	// It might be possible to try invoking them and see that they do the right things, at some point
	// For now, too much bother.

	c.Assert(createdMenu.GetMenuItemByName("Check Connection").onActivate, Not(IsNil))
	c.Assert(createdMenu.GetMenuItemByName("Connect").onActivate, Not(IsNil))
	c.Assert(createdMenu.GetMenuItemByName("Disconnect").onActivate, Not(IsNil))

	c.Assert(createdMenu.GetMenuItemByName("Edit").onActivate, Not(IsNil))
	c.Assert(createdMenu.GetMenuItemByName("Remove").onActivate, Not(IsNil))

	c.Assert(createdMenu.GetCheckMenuItemByName("Connect Automatically").onActivate, Not(IsNil))
	c.Assert(createdMenu.GetCheckMenuItemByName("Always Encrypt Conversation").onActivate, Not(IsNil))
}
Exemple #9
0
func init() {
	log.SetOutput(ioutil.Discard)
	i18n.InitLocalization(&glib_mock.Mock{})
}
Exemple #10
0
func (*TCPSuite) SetUpSuite(c *C) {
	log.SetOutput(ioutil.Discard)
	i18n.InitLocalization(&glib_mock.Mock{})
}