diff options
Diffstat (limited to 'Slimber')
-rw-r--r-- | Slimber/CLI/DummyMenulet.h | 4 | ||||
-rw-r--r-- | Slimber/Cocoa/CocoaMenulet.h | 4 | ||||
-rw-r--r-- | Slimber/Cocoa/CocoaMenulet.mm | 14 | ||||
-rw-r--r-- | Slimber/FileVCardCollection.cpp | 2 | ||||
-rw-r--r-- | Slimber/LinkLocalPresenceManager.cpp | 12 | ||||
-rw-r--r-- | Slimber/LinkLocalPresenceManager.h | 4 | ||||
-rw-r--r-- | Slimber/MainController.cpp | 14 | ||||
-rw-r--r-- | Slimber/Menulet.h | 6 | ||||
-rw-r--r-- | Slimber/MenuletController.cpp | 12 | ||||
-rw-r--r-- | Slimber/MenuletController.h | 10 | ||||
-rw-r--r-- | Slimber/Qt/QtMenulet.h | 10 | ||||
-rw-r--r-- | Slimber/Server.cpp | 13 | ||||
-rw-r--r-- | Slimber/Server.h | 4 | ||||
-rw-r--r-- | Slimber/ServerError.h | 8 | ||||
-rw-r--r-- | Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp | 26 | ||||
-rw-r--r-- | Slimber/UnitTest/MenuletControllerTest.cpp | 74 |
16 files changed, 106 insertions, 111 deletions
diff --git a/Slimber/CLI/DummyMenulet.h b/Slimber/CLI/DummyMenulet.h index e0bcb2f..56cc9ce 100644 --- a/Slimber/CLI/DummyMenulet.h +++ b/Slimber/CLI/DummyMenulet.h @@ -16,7 +16,7 @@ class DummyMenulet : public Menulet { void clear() { } - void addItem(const Swift::String&, const Swift::String&) { + void addItem(const std::string&, const std::string&) { } void addAboutItem() { @@ -31,6 +31,6 @@ class DummyMenulet : public Menulet { void addSeparator() { } - void setIcon(const Swift::String&) { + void setIcon(const std::string&) { } }; diff --git a/Slimber/Cocoa/CocoaMenulet.h b/Slimber/Cocoa/CocoaMenulet.h index 292c8b9..7f2758b 100644 --- a/Slimber/Cocoa/CocoaMenulet.h +++ b/Slimber/Cocoa/CocoaMenulet.h @@ -18,9 +18,9 @@ class CocoaMenulet : public Menulet { private: virtual void clear(); - virtual void addItem(const Swift::String& name, const Swift::String& icon); + virtual void addItem(const std::string& name, const std::string& icon); virtual void addSeparator(); - void setIcon(const Swift::String& icon); + void setIcon(const std::string& icon); virtual void addAboutItem(); virtual void addRestartItem(); virtual void addExitItem(); diff --git a/Slimber/Cocoa/CocoaMenulet.mm b/Slimber/Cocoa/CocoaMenulet.mm index 90e699f..de9e9e9 100644 --- a/Slimber/Cocoa/CocoaMenulet.mm +++ b/Slimber/Cocoa/CocoaMenulet.mm @@ -4,8 +4,6 @@ #include <boost/function.hpp> -using namespace Swift; - CocoaMenulet::CocoaMenulet() { restartAction = [[CocoaAction alloc] initWithFunction: new boost::function<void()>(boost::ref(onRestartClicked))]; @@ -25,9 +23,9 @@ CocoaMenulet::~CocoaMenulet() { [restartAction release]; } -void CocoaMenulet::setIcon(const String& icon) { +void CocoaMenulet::setIcon(const std::string& icon) { NSString* path = [[NSBundle mainBundle] pathForResource: - [NSString stringWithUTF8String: icon.getUTF8Data()] ofType:@"png"]; + [NSString stringWithUTF8String: icon.c_str()] ofType:@"png"]; NSImage* image = [[NSImage alloc] initWithContentsOfFile: path]; [statusItem setImage: image]; [image release]; @@ -39,13 +37,13 @@ void CocoaMenulet::clear() { } } -void CocoaMenulet::addItem(const Swift::String& name, const String& icon) { +void CocoaMenulet::addItem(const std::string& name, const std::string& icon) { NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: - [NSString stringWithUTF8String: name.getUTF8Data()] + [NSString stringWithUTF8String: name.c_str()] action: NULL keyEquivalent: @""]; - if (!icon.isEmpty()) { + if (!icon.empty()) { NSString* path = [[NSBundle mainBundle] pathForResource: - [NSString stringWithUTF8String: icon.getUTF8Data()] ofType:@"png"]; + [NSString stringWithUTF8String: icon.c_str()] ofType:@"png"]; NSImage* image = [[NSImage alloc] initWithContentsOfFile: path]; [item setImage: [[NSImage alloc] initWithContentsOfFile: path]]; [image release]; diff --git a/Slimber/FileVCardCollection.cpp b/Slimber/FileVCardCollection.cpp index 6a8b6b1..9fab068 100644 --- a/Slimber/FileVCardCollection.cpp +++ b/Slimber/FileVCardCollection.cpp @@ -26,7 +26,7 @@ boost::shared_ptr<VCard> FileVCardCollection::getOwnVCard() const { VCardParser parser; PayloadParserTester tester(&parser); - tester.parse(String(data.getData(), data.getSize())); + tester.parse(std::string(data.getData(), data.getSize())); return boost::dynamic_pointer_cast<VCard>(parser.getPayload()); } else { diff --git a/Slimber/LinkLocalPresenceManager.cpp b/Slimber/LinkLocalPresenceManager.cpp index 465d849..edb7e91 100644 --- a/Slimber/LinkLocalPresenceManager.cpp +++ b/Slimber/LinkLocalPresenceManager.cpp @@ -70,19 +70,19 @@ RosterItemPayload LinkLocalPresenceManager::getRosterItem(const LinkLocalService return RosterItemPayload(service.getJID(), getRosterName(service), RosterItemPayload::Both); } -String LinkLocalPresenceManager::getRosterName(const LinkLocalService& service) const { +std::string LinkLocalPresenceManager::getRosterName(const LinkLocalService& service) const { LinkLocalServiceInfo info = service.getInfo(); - if (!info.getNick().isEmpty()) { + if (!info.getNick().empty()) { return info.getNick(); } - else if (!info.getFirstName().isEmpty()) { - String result = info.getFirstName(); - if (!info.getLastName().isEmpty()) { + else if (!info.getFirstName().empty()) { + std::string result = info.getFirstName(); + if (!info.getLastName().empty()) { result += " " + info.getLastName(); } return result; } - else if (!info.getLastName().isEmpty()) { + else if (!info.getLastName().empty()) { return info.getLastName(); } return ""; diff --git a/Slimber/LinkLocalPresenceManager.h b/Slimber/LinkLocalPresenceManager.h index 25069fa..26bb7ce 100644 --- a/Slimber/LinkLocalPresenceManager.h +++ b/Slimber/LinkLocalPresenceManager.h @@ -10,7 +10,7 @@ #include "Swiften/Base/boost_bsignals.h" #include "Swiften/Elements/RosterItemPayload.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" namespace Swift { @@ -37,7 +37,7 @@ namespace Swift { void handleServiceRemoved(const LinkLocalService&); RosterItemPayload getRosterItem(const LinkLocalService& service) const; - String getRosterName(const LinkLocalService& service) const; + std::string getRosterName(const LinkLocalService& service) const; boost::shared_ptr<Presence> getPresence(const LinkLocalService& service) const; private: diff --git a/Slimber/MainController.cpp b/Slimber/MainController.cpp index e6c2ab5..e39a660 100644 --- a/Slimber/MainController.cpp +++ b/Slimber/MainController.cpp @@ -86,9 +86,9 @@ void MainController::handleSelfConnected(bool b) { } void MainController::handleServicesChanged() { - std::vector<String> names; + std::vector<std::string> names; foreach(const LinkLocalService& service, linkLocalServiceBrowser->getServices()) { - String description = service.getDescription(); + std::string description = service.getDescription(); if (description != service.getName()) { description += " (" + service.getName() + ")"; } @@ -99,19 +99,19 @@ void MainController::handleServicesChanged() { void MainController::handleServerStopped(boost::optional<ServerError> error) { if (error) { - String message; + std::string message; switch (error->getType()) { case ServerError::C2SPortConflict: - message = String("Error: Port ") + boost::lexical_cast<std::string>(server->getClientToServerPort()) + String(" in use"); + message = std::string("Error: Port ") + boost::lexical_cast<std::string>(server->getClientToServerPort()) + std::string(" in use"); break; case ServerError::C2SError: - message = String("Local connection server error"); + message = std::string("Local connection server error"); break; case ServerError::LinkLocalPortConflict: - message = String("Error: Port ") + boost::lexical_cast<std::string>(server->getLinkLocalPort()) + String(" in use"); + message = std::string("Error: Port ") + boost::lexical_cast<std::string>(server->getLinkLocalPort()) + std::string(" in use"); break; case ServerError::LinkLocalError: - message = String("External connection server error"); + message = std::string("External connection server error"); break; } menuletController->setXMPPStatus(message, MenuletController::Offline); diff --git a/Slimber/Menulet.h b/Slimber/Menulet.h index 6ecdcc5..df3c32c 100644 --- a/Slimber/Menulet.h +++ b/Slimber/Menulet.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/boost_bsignals.h" class Menulet { @@ -14,12 +14,12 @@ class Menulet { virtual ~Menulet(); virtual void clear() = 0; - virtual void addItem(const Swift::String& name, const Swift::String& icon = Swift::String()) = 0; + virtual void addItem(const std::string& name, const std::string& icon = std::string()) = 0; virtual void addAboutItem() = 0; virtual void addRestartItem() = 0; virtual void addExitItem() = 0; virtual void addSeparator() = 0; - virtual void setIcon(const Swift::String&) = 0; + virtual void setIcon(const std::string&) = 0; boost::signal<void ()> onRestartClicked; }; diff --git a/Slimber/MenuletController.cpp b/Slimber/MenuletController.cpp index 1155c81..351db21 100644 --- a/Slimber/MenuletController.cpp +++ b/Slimber/MenuletController.cpp @@ -7,13 +7,11 @@ #include "Slimber/MenuletController.h" #include "Swiften/Base/foreach.h" -#include "Swiften/Base/String.h" +#include <string> #include "Slimber/Menulet.h" #include <iostream> -using namespace Swift; - MenuletController::MenuletController(Menulet* menulet) : menulet(menulet), xmppStatus(Offline) { menulet->onRestartClicked.connect(boost::ref(onRestartRequested)); @@ -23,13 +21,13 @@ MenuletController::MenuletController(Menulet* menulet) : MenuletController::~MenuletController() { } -void MenuletController::setXMPPStatus(const String& message, Status status) { +void MenuletController::setXMPPStatus(const std::string& message, Status status) { xmppStatus = status; xmppStatusMessage = message; update(); } -void MenuletController::setUserNames(const std::vector<String>& users) { +void MenuletController::setUserNames(const std::vector<std::string>& users) { linkLocalUsers = users; update(); } @@ -43,8 +41,8 @@ void MenuletController::update() { else { menulet->setIcon("UsersOnline"); menulet->addItem("Online users:"); - foreach(const String& user, linkLocalUsers) { - menulet->addItem(String(" ") + user); + foreach(const std::string& user, linkLocalUsers) { + menulet->addItem(std::string(" ") + user); } } menulet->addSeparator(); diff --git a/Slimber/MenuletController.h b/Slimber/MenuletController.h index 6b7f6fd..31b2d83 100644 --- a/Slimber/MenuletController.h +++ b/Slimber/MenuletController.h @@ -9,7 +9,7 @@ #include <vector> #include <boost/signal.hpp> -#include "Swiften/Base/String.h" +#include <string> class Menulet; @@ -23,8 +23,8 @@ class MenuletController { MenuletController(Menulet*); virtual ~MenuletController(); - void setXMPPStatus(const Swift::String& message, Status status); - void setUserNames(const std::vector<Swift::String>&); + void setXMPPStatus(const std::string& message, Status status); + void setUserNames(const std::vector<std::string>&); boost::signal<void ()> onRestartRequested; @@ -34,6 +34,6 @@ class MenuletController { private: Menulet* menulet; Status xmppStatus; - Swift::String xmppStatusMessage; - std::vector<Swift::String> linkLocalUsers; + std::string xmppStatusMessage; + std::vector<std::string> linkLocalUsers; }; diff --git a/Slimber/Qt/QtMenulet.h b/Slimber/Qt/QtMenulet.h index 08bae0c..01a9db1 100644 --- a/Slimber/Qt/QtMenulet.h +++ b/Slimber/Qt/QtMenulet.h @@ -30,8 +30,8 @@ class QtMenulet : public QObject, public Menulet { menu.clear(); } - void addItem(const Swift::String& name, const Swift::String& icon) { - menu.addAction(getIcon(icon), QString::fromUtf8(name.getUTF8Data())); + void addItem(const std::string& name, const std::string& icon) { + menu.addAction(getIcon(icon), QString::fromUtf8(name.c_str())); } void addAboutItem() { @@ -50,13 +50,13 @@ class QtMenulet : public QObject, public Menulet { menu.addSeparator(); } - void setIcon(const Swift::String& icon) { + void setIcon(const std::string& icon) { trayIcon.setIcon(getIcon(icon)); } private: - QPixmap getIcon(const Swift::String& name) { - return QPixmap(":/icons/" + QString::fromUtf8(name.getUTF8Data()) + ".png"); + QPixmap getIcon(const std::string& name) { + return QPixmap(":/icons/" + QString::fromUtf8(name.c_str()) + ".png"); } private slots: diff --git a/Slimber/Server.cpp b/Slimber/Server.cpp index b8cffb0..380ce6a 100644 --- a/Slimber/Server.cpp +++ b/Slimber/Server.cpp @@ -9,6 +9,7 @@ #include <string> #include <boost/bind.hpp> +#include "Swiften/Base/String.h" #include "Swiften/LinkLocal/LinkLocalConnector.h" #include "Swiften/Network/Connection.h" #include "Swiften/Session/SessionTracer.h" @@ -21,7 +22,7 @@ #include "Swiften/Elements/IQ.h" #include "Swiften/Elements/VCard.h" #include "Swiften/Server/UserRegistry.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/LinkLocal/LinkLocalServiceInfo.h" #include "Swiften/LinkLocal/OutgoingLinkLocalSession.h" #include "Swiften/LinkLocal/IncomingLinkLocalSession.h" @@ -397,19 +398,19 @@ void Server::handleLinkLocalConnectionServerStopped(boost::optional<BoostConnect LinkLocalServiceInfo Server::getLinkLocalServiceInfo(boost::shared_ptr<Presence> presence) { LinkLocalServiceInfo info; boost::shared_ptr<VCard> vcard = vCardCollection->getOwnVCard(); - if (!vcard->getFamilyName().isEmpty() || !vcard->getGivenName().isEmpty()) { + if (!vcard->getFamilyName().empty() || !vcard->getGivenName().empty()) { info.setFirstName(vcard->getGivenName()); info.setLastName(vcard->getFamilyName()); } - else if (!vcard->getFullName().isEmpty()) { - std::pair<String,String> p = vcard->getFullName().getSplittedAtFirst(' '); + else if (!vcard->getFullName().empty()) { + std::pair<std::string,std::string> p = String::getSplittedAtFirst(vcard->getFullName(), ' '); info.setFirstName(p.first); info.setLastName(p.second); } - if (!vcard->getNickname().isEmpty()) { + if (!vcard->getNickname().empty()) { info.setNick(vcard->getNickname()); } - if (!vcard->getPreferredEMailAddress().address.isEmpty()) { + if (!vcard->getPreferredEMailAddress().address.empty()) { info.setEMail(vcard->getPreferredEMailAddress().address); } info.setMessage(presence->getStatus()); diff --git a/Slimber/Server.h b/Slimber/Server.h index 039f351..98332fd 100644 --- a/Slimber/Server.h +++ b/Slimber/Server.h @@ -23,7 +23,7 @@ namespace Swift { class DNSSDServiceID; - class String; + class VCardCollection; class LinkLocalConnector; class LinkLocalServiceBrowser; @@ -87,7 +87,7 @@ namespace Swift { public: DummyUserRegistry() {} - virtual bool isValidUserPassword(const JID&, const String&) const { + virtual bool isValidUserPassword(const JID&, const std::string&) const { return true; } }; diff --git a/Slimber/ServerError.h b/Slimber/ServerError.h index ad09275..ec80f0a 100644 --- a/Slimber/ServerError.h +++ b/Slimber/ServerError.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class ServerError { @@ -18,7 +18,7 @@ namespace Swift { LinkLocalError }; - ServerError(Type type, const String& message = String()) : + ServerError(Type type, const std::string& message = std::string()) : type(type), message(message) { } @@ -26,12 +26,12 @@ namespace Swift { return type; } - const String& getMessage() const { + const std::string& getMessage() const { return message; } private: Type type; - String message; + std::string message; }; } diff --git a/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp b/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp index 8c6710a..47eb05c 100644 --- a/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp +++ b/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp @@ -71,7 +71,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(rosterChanges[0]->getItems().size())); boost::optional<RosterItemPayload> item = rosterChanges[0]->getItem(JID("alice@wonderland")); CPPUNIT_ASSERT(item); - CPPUNIT_ASSERT_EQUAL(String("Alice"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), item->getName()); CPPUNIT_ASSERT_EQUAL(RosterItemPayload::Both, item->getSubscription()); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(presenceChanges.size())); CPPUNIT_ASSERT(StatusShow::Online == presenceChanges[0]->getShow()); @@ -101,7 +101,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(presenceChanges.size())); CPPUNIT_ASSERT(StatusShow::Away == presenceChanges[1]->getShow()); CPPUNIT_ASSERT(JID("alice@wonderland") == presenceChanges[1]->getFrom()); - CPPUNIT_ASSERT_EQUAL(String("I'm Away"), presenceChanges[1]->getStatus()); + CPPUNIT_ASSERT_EQUAL(std::string("I'm Away"), presenceChanges[1]->getStatus()); } void testGetAllPresence() { @@ -131,11 +131,11 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { boost::optional<RosterItemPayload> item; item = roster->getItem(JID("alice@wonderland")); CPPUNIT_ASSERT(item); - CPPUNIT_ASSERT_EQUAL(String("Alice"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), item->getName()); CPPUNIT_ASSERT_EQUAL(RosterItemPayload::Both, item->getSubscription()); item = roster->getItem(JID("rabbit@teaparty")); CPPUNIT_ASSERT(item); - CPPUNIT_ASSERT_EQUAL(String("Rabbit"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Rabbit"), item->getName()); CPPUNIT_ASSERT_EQUAL(RosterItemPayload::Both, item->getSubscription()); } @@ -145,7 +145,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland", "Alice", "Alice In", "Wonderland"); boost::optional<RosterItemPayload> item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String("Alice"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), item->getName()); } void testGetRoster_InfoWithFirstName() { @@ -154,7 +154,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland", "", "Alice In", ""); boost::optional<RosterItemPayload> item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String("Alice In"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In"), item->getName()); } void testGetRoster_InfoWithLastName() { @@ -163,7 +163,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland", "", "", "Wonderland"); boost::optional<RosterItemPayload> item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String("Wonderland"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Wonderland"), item->getName()); } void testGetRoster_InfoWithFirstAndLastName() { @@ -172,7 +172,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland", "", "Alice In", "Wonderland"); boost::optional<RosterItemPayload> item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String("Alice In Wonderland"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland"), item->getName()); } void testGetRoster_NoInfo() { @@ -181,7 +181,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland"); boost::optional<RosterItemPayload> item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String(""), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string(""), item->getName()); } void testGetServiceForJID() { @@ -193,7 +193,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { boost::optional<LinkLocalService> service = testling->getServiceForJID(JID("rabbit@teaparty")); CPPUNIT_ASSERT(service); - CPPUNIT_ASSERT_EQUAL(String("rabbit@teaparty"), service->getID().getName()); + CPPUNIT_ASSERT_EQUAL(std::string("rabbit@teaparty"), service->getID().getName()); } void testGetServiceForJID_NoMatch() { @@ -216,7 +216,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { return testling; } - void addService(const String& name, const String& nickName = String(), const String& firstName = String(), const String& lastName = String()) { + void addService(const std::string& name, const std::string& nickName = std::string(), const std::string& firstName = std::string(), const std::string& lastName = std::string()) { DNSSDServiceID service(name, "local."); LinkLocalServiceInfo info; info.setFirstName(firstName); @@ -227,13 +227,13 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { eventLoop->processEvents(); } - void removeService(const String& name) { + void removeService(const std::string& name) { DNSSDServiceID service(name, "local."); querier->removeService(DNSSDServiceID(name, "local.")); eventLoop->processEvents(); } - void updateServicePresence(const String& name, LinkLocalServiceInfo::Status status, const String& message) { + void updateServicePresence(const std::string& name, LinkLocalServiceInfo::Status status, const std::string& message) { DNSSDServiceID service(name, "local."); LinkLocalServiceInfo info; info.setStatus(status); diff --git a/Slimber/UnitTest/MenuletControllerTest.cpp b/Slimber/UnitTest/MenuletControllerTest.cpp index 9722125..092a886 100644 --- a/Slimber/UnitTest/MenuletControllerTest.cpp +++ b/Slimber/UnitTest/MenuletControllerTest.cpp @@ -10,8 +10,6 @@ #include "Slimber/Menulet.h" #include "Slimber/MenuletController.h" -using namespace Swift; - class MenuletControllerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(MenuletControllerTest); CPPUNIT_TEST(testConstructor); @@ -36,14 +34,14 @@ class MenuletControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(8, static_cast<int>(menulet->items.size())); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("[Offline] "), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*About*"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*Restart*"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*Exit*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("[Offline] "), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*About*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*Restart*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*Exit*"), menulet->items[i++]); } void testUpdate() { @@ -53,14 +51,14 @@ class MenuletControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(8, static_cast<int>(menulet->items.size())); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("[Online] You are connected"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*About*"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*Restart*"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*Exit*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("[Online] You are connected"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*About*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*Restart*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*Exit*"), menulet->items[i++]); } void testSetXMPPStatus_Online() { @@ -69,9 +67,9 @@ class MenuletControllerTest : public CppUnit::TestFixture { testling.setXMPPStatus("You are connected", MenuletController::Online); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("[Online] You are connected"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("[Online] You are connected"), menulet->items[i++]); } @@ -81,35 +79,35 @@ class MenuletControllerTest : public CppUnit::TestFixture { testling.setXMPPStatus("You are not connected", MenuletController::Offline); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("[Offline] You are not connected"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("[Offline] You are not connected"), menulet->items[i++]); } void testSetUserNames() { MenuletController testling(menulet); - std::vector<String> users; + std::vector<std::string> users; users.push_back("Alice In Wonderland"); users.push_back("The Mad Hatter"); testling.setUserNames(users); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("Online users:"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String(" Alice In Wonderland"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String(" The Mad Hatter"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("Online users:"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string(" Alice In Wonderland"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string(" The Mad Hatter"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); } void testSetUserNames_NoUsers() { MenuletController testling(menulet); - std::vector<String> users; + std::vector<std::string> users; testling.setUserNames(users); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); } private: @@ -118,9 +116,9 @@ class MenuletControllerTest : public CppUnit::TestFixture { items.clear(); } - virtual void addItem(const String& name, const String& icon = String()) { - String result; - if (!icon.isEmpty()) { + virtual void addItem(const std::string& name, const std::string& icon = std::string()) { + std::string result; + if (!icon.empty()) { result += "[" + icon + "] "; } result += name; @@ -143,12 +141,12 @@ class MenuletControllerTest : public CppUnit::TestFixture { items.push_back("-"); } - virtual void setIcon(const String& i) { + virtual void setIcon(const std::string& i) { icon = i; } - std::vector<String> items; - String icon; + std::vector<std::string> items; + std::string icon; }; FakeMenulet* menulet; |