diff options
| author | handsome_feng <445865575@qq.com> | 2016-03-02 11:02:38 +0800 |
|---|---|---|
| committer | handsome_feng <445865575@qq.com> | 2016-03-02 11:02:38 +0800 |
| commit | cf2edecfa871318641d261e61358289f5aead8f8 (patch) | |
| tree | bc436c75bb36e4e51e0e3614fe9cd6da673c8a99 /tests | |
| parent | da0f5bad254a4f827c6629078c688b8541911fdb (diff) | |
| parent | 6a53f55de17e56e3ae2ccabf8fcc716a7db28462 (diff) | |
merge trunk
(bzr r4067.4.10)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/data/applications/org.gnome.Software.desktop (renamed from tests/data/applications/ubuntu-software-center.desktop) | 7 | ||||
| -rw-r--r-- | tests/test_application_launcher_icon.cpp | 14 | ||||
| -rw-r--r-- | tests/test_desktop_utilities.cpp | 6 | ||||
| -rw-r--r-- | tests/test_favorite_store.cpp | 2 | ||||
| -rw-r--r-- | tests/test_favorite_store_gsettings.cpp | 2 | ||||
| -rw-r--r-- | tests/test_launcher_controller.cpp | 34 | ||||
| -rw-r--r-- | tests/test_software_center_launcher_icon.cpp | 132 |
7 files changed, 45 insertions, 152 deletions
diff --git a/tests/data/applications/ubuntu-software-center.desktop b/tests/data/applications/org.gnome.Software.desktop index d633a43ac..7481fd62d 100644 --- a/tests/data/applications/ubuntu-software-center.desktop +++ b/tests/data/applications/org.gnome.Software.desktop @@ -1,9 +1,8 @@ [Desktop Entry] -Name=Ubuntu Software Center -GenericName=Software Center -Comment=Lets you choose from thousands of applications available for Ubuntu +Name=Software +Comment=Add, remove or update software on this computer Exec=/bin/true -Icon=softwarecenter +Icon=org.gnome.Software Terminal=false Type=Application Categories=PackageManager;GTK;System;Settings; diff --git a/tests/test_application_launcher_icon.cpp b/tests/test_application_launcher_icon.cpp index c34c39b6c..610417c91 100644 --- a/tests/test_application_launcher_icon.cpp +++ b/tests/test_application_launcher_icon.cpp @@ -41,7 +41,7 @@ using namespace unity::launcher; namespace { const std::string DEFAULT_EMPTY_ICON = "application-default-icon"; -const std::string USC_DESKTOP = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop"; +const std::string GS_DESKTOP = BUILDDIR"/tests/data/applications/org.gnome.Software.desktop"; const std::string UM_DESKTOP = BUILDDIR"/tests/data/applications/update-manager.desktop"; const std::string NO_ICON_DESKTOP = BUILDDIR"/tests/data/applications/no-icon.desktop"; @@ -93,9 +93,9 @@ struct TestApplicationLauncherIcon : testmocks::TestUnityAppBase virtual void SetUp() override { - usc_app = std::make_shared<MockApplication::Nice>(USC_DESKTOP, "softwarecenter"); + usc_app = std::make_shared<MockApplication::Nice>(GS_DESKTOP, "org.gnome.Software"); usc_icon = new MockApplicationLauncherIcon(usc_app); - ASSERT_EQ(usc_icon->DesktopFile(), USC_DESKTOP); + ASSERT_EQ(usc_icon->DesktopFile(), GS_DESKTOP); empty_app = std::make_shared<MockApplication::Nice>(NO_ICON_DESKTOP); empty_icon = new MockApplicationLauncherIcon(empty_app); @@ -175,7 +175,7 @@ struct TestApplicationLauncherIcon : testmocks::TestUnityAppBase TEST_F(TestApplicationLauncherIcon, ApplicationSignalDisconnection) { - std::shared_ptr<MockApplication> app = std::make_shared<MockApplication::Nice>(USC_DESKTOP); + std::shared_ptr<MockApplication> app = std::make_shared<MockApplication::Nice>(GS_DESKTOP); { MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app)); EXPECT_FALSE(app->closed.empty()); @@ -201,7 +201,7 @@ TEST_F(TestApplicationLauncherIcon, TestCustomBackgroundColor) TEST_F(TestApplicationLauncherIcon, TestDefaultIcon) { - EXPECT_EQ(usc_icon->icon_name(), "softwarecenter"); + EXPECT_EQ(usc_icon->icon_name(), "org.gnome.Software"); EXPECT_EQ(empty_icon->icon_name(), DEFAULT_EMPTY_ICON); EXPECT_EQ(mock_icon->icon_name(), DEFAULT_EMPTY_ICON); } @@ -267,7 +267,7 @@ TEST_F(TestApplicationLauncherIcon, StickAndSaveDesktopLessApp) TEST_F(TestApplicationLauncherIcon, StickStickedDesktopApp) { - auto app = std::make_shared<MockApplication::Nice>(USC_DESKTOP); + auto app = std::make_shared<MockApplication::Nice>(GS_DESKTOP); app->sticky = true; app->desktop_file_ = UM_DESKTOP; MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app)); @@ -542,7 +542,7 @@ TEST_F(TestApplicationLauncherIcon, UpdateDesktopForgetsOldPositionUpdatesUriAnd TEST_F(TestApplicationLauncherIcon, RemoteUri) { - EXPECT_EQ(usc_icon->RemoteUri(), FavoriteStore::URI_PREFIX_APP + USC_DESKTOP); + EXPECT_EQ(usc_icon->RemoteUri(), FavoriteStore::URI_PREFIX_APP + GS_DESKTOP); EXPECT_TRUE(mock_icon->RemoteUri().empty()); } diff --git a/tests/test_desktop_utilities.cpp b/tests/test_desktop_utilities.cpp index b8726b943..f77b9ac3e 100644 --- a/tests/test_desktop_utilities.cpp +++ b/tests/test_desktop_utilities.cpp @@ -184,17 +184,17 @@ TEST(TestDesktopUtilities, TestGetDesktopPathById) g_setenv("XDG_DATA_DIRS", LOCAL_DATA_DIR.c_str(), TRUE); g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE); - std::string const& file = DesktopUtilities::GetDesktopPathById("ubuntu-software-center.desktop"); + std::string const& file = DesktopUtilities::GetDesktopPathById("org.gnome.Software.desktop"); g_setenv("XDG_DATA_DIRS", old_dirs.c_str(), TRUE); g_setenv("XDG_DATA_HOME", old_dirs.c_str(), TRUE); - EXPECT_EQ(file, LOCAL_DATA_DIR + "/applications/ubuntu-software-center.desktop"); + EXPECT_EQ(file, LOCAL_DATA_DIR + "/applications/org.gnome.Software.desktop"); } TEST(TestDesktopUtilities, TestGetBackgroundColor) { - std::string const& color = DesktopUtilities::GetBackgroundColor(LOCAL_DATA_DIR+"/applications/ubuntu-software-center.desktop"); + std::string const& color = DesktopUtilities::GetBackgroundColor(LOCAL_DATA_DIR+"/applications/org.gnome.Software.desktop"); EXPECT_EQ(color, "#aabbcc"); } diff --git a/tests/test_favorite_store.cpp b/tests/test_favorite_store.cpp index 3fd0d1bd3..da9089189 100644 --- a/tests/test_favorite_store.cpp +++ b/tests/test_favorite_store.cpp @@ -87,7 +87,7 @@ TEST_F(TestFavoriteStore, IsValidFavoriteUri) TEST_F(TestFavoriteStore, ParseFavoriteFromUri) { - const std::string VALID_DESKTOP_PATH = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop"; + const std::string VALID_DESKTOP_PATH = BUILDDIR"/tests/data/applications/org.gnome.Software.desktop"; EXPECT_EQ(favorite_store.ParseFavoriteFromUri("file.desktop"), "application://file.desktop"); EXPECT_EQ(favorite_store.ParseFavoriteFromUri(VALID_DESKTOP_PATH), "application://"+VALID_DESKTOP_PATH); diff --git a/tests/test_favorite_store_gsettings.cpp b/tests/test_favorite_store_gsettings.cpp index 9f9c1b4b0..a1b584238 100644 --- a/tests/test_favorite_store_gsettings.cpp +++ b/tests/test_favorite_store_gsettings.cpp @@ -38,7 +38,7 @@ const gchar* SETTINGS_NAME = "com.canonical.Unity.Launcher"; const gchar* SETTINGS_KEY = "favorites"; const char* base_store_favs[] = { BUILDDIR"/tests/data/applications/ubuntuone-installer.desktop", - "file://" BUILDDIR "/tests/data/applications/ubuntu-software-center.desktop", + "file://" BUILDDIR "/tests/data/applications/org.gnome.Software.desktop", "application://" BUILDDIR "/tests/data/applications/update-manager.desktop", "unity://test-icon", "device://uuid", diff --git a/tests/test_launcher_controller.cpp b/tests/test_launcher_controller.cpp index a90005ef7..7cf9455b0 100644 --- a/tests/test_launcher_controller.cpp +++ b/tests/test_launcher_controller.cpp @@ -62,7 +62,7 @@ const std::string DEVICES_URI = "unity://devices"; namespace app { const std::string UBUNTU_ONE = BUILDDIR "/tests/data/applications/ubuntuone-installer.desktop"; - const std::string SW_CENTER = BUILDDIR "/tests/data/applications/ubuntu-software-center.desktop"; + const std::string SW_CENTER = BUILDDIR "/tests/data/applications/org.gnome.Software.desktop"; const std::string UPDATE_MANAGER = BUILDDIR "/tests/data/applications/update-manager.desktop"; const std::string BZR_HANDLE_PATCH = BUILDDIR "/tests/data/applications/bzr-handle-patch.desktop"; const std::string NO_ICON = BUILDDIR "/tests/data/applications/no-icon.desktop"; @@ -1341,38 +1341,6 @@ TEST_F(TestLauncherController, LauncherRemoveRequestDeviceStops) lc.launcher().remove_request.emit(device_icon); } -TEST_F(TestLauncherController, LauncherAddRequestSpecial) -{ - std::string desktop = app::BZR_HANDLE_PATCH; - std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop; - ASSERT_FALSE(lc.Impl()->GetIconByUri(icon_uri).IsValid()); - EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); - - lc.Impl()->OnLauncherAddRequestSpecial(desktop, "", "", 0, 0, 32); - - auto const& sw_center_icon = lc.Impl()->GetIconByUri(icon_uri); - ASSERT_TRUE(sw_center_icon.IsValid()); - EXPECT_TRUE(sw_center_icon->IsSticky()); - EXPECT_NE(dynamic_cast<SoftwareCenterLauncherIcon*>(sw_center_icon.GetPointer()), nullptr); -} - -TEST_F(TestLauncherController, LauncherAddRequestSpecialIgnored) -{ - std::string desktop = app::BZR_HANDLE_PATCH; - std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop; - - MockApplicationLauncherIcon::Ptr bamf_icon(new MockApplicationLauncherIcon::Nice(desktop)); - lc.Impl()->RegisterIcon(bamf_icon, std::numeric_limits<int>::max()); - ASSERT_TRUE(lc.Impl()->GetIconByUri(icon_uri).IsValid()); - - EXPECT_CALL(*bamf_icon, Stick(false)).Times(0); - - int previous_model_size = lc.Impl()->model_->Size(); - lc.Impl()->OnLauncherAddRequestSpecial(desktop, "", "", 0, 0, 32); - - EXPECT_EQ(previous_model_size, lc.Impl()->model_->Size()); -} - TEST_F(TestLauncherController, SaveIconsOrder) { favorite_store.ClearFavorites(); diff --git a/tests/test_software_center_launcher_icon.cpp b/tests/test_software_center_launcher_icon.cpp index 6ee4d8d12..98ef81d4d 100644 --- a/tests/test_software_center_launcher_icon.cpp +++ b/tests/test_software_center_launcher_icon.cpp @@ -42,28 +42,26 @@ namespace launcher { namespace { -const std::string PRE_INSTALL_ICON = "sw-center-launcher-icon"; -const std::string FINAL_ICON = "softwarecenter"; -const std::string APP_NAME = "Ubuntu Software Center"; +const std::string FINAL_ICON = "org.gnome.Software"; +const std::string APP_NAME = "Software"; const std::string LOCAL_DATA_DIR = BUILDDIR"/tests/data"; -const std::string USC_DESKTOP = LOCAL_DATA_DIR+"/applications/ubuntu-software-center.desktop"; -const std::string USC_APP_INSTALL_DESKTOP = "/usr/share/app-install/desktop/software-center:ubuntu-software-center.desktop"; +const std::string GS_DESKTOP = LOCAL_DATA_DIR+"/applications/org.gnome.Software.desktop"; +const std::string GS_APP_INSTALL_DESKTOP = "org.gnome.Software.desktop"; } struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase { TestSoftwareCenterLauncherIcon() - : usc(std::make_shared<MockApplication::Nice>(USC_APP_INSTALL_DESKTOP, FINAL_ICON, APP_NAME)) - , icon(usc, "/com/canonical/unity/test/object/path", PRE_INSTALL_ICON) + : gs(std::make_shared<MockApplication::Nice>(GS_APP_INSTALL_DESKTOP, FINAL_ICON, APP_NAME)) + , icon(gs, "/com/canonical/unity/test/object/path") {} struct MockSoftwareCenterLauncherIcon : SoftwareCenterLauncherIcon { MockSoftwareCenterLauncherIcon(ApplicationPtr const& app, - std::string const& aptdaemon_trans_id, - std::string const& icon_path) + std::string const& aptdaemon_trans_id) : WindowedLauncherIcon(IconType::APPLICATION) - , SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path) + , SoftwareCenterLauncherIcon(app, aptdaemon_trans_id) {} void LauncherIconUnstick() { LauncherIcon::UnStick(); } @@ -71,7 +69,6 @@ struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall; using SoftwareCenterLauncherIcon::OnFinished; using SoftwareCenterLauncherIcon::OnPropertyChanged; - using SoftwareCenterLauncherIcon::drag_window_; using LauncherIcon::GetRemoteUri; }; @@ -86,7 +83,7 @@ struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase panel::Style panel; nux::ObjectPtr<MockableBaseWindow> launcher_win; - MockApplication::Ptr usc; + MockApplication::Ptr gs; MockSoftwareCenterLauncherIcon icon; }; @@ -94,75 +91,54 @@ TEST_F(TestSoftwareCenterLauncherIcon, Construction) { EXPECT_FALSE(icon.IsVisible()); EXPECT_TRUE(icon.IsSticky()); - EXPECT_EQ(AbstractLauncherIcon::Position::FLOATING, icon.position()); EXPECT_EQ("Waiting to install", icon.tooltip_text()); - EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name()); } TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformTrivial) { // no transformation needed - usc->desktop_file_ = USC_DESKTOP; - EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), USC_DESKTOP); + gs->desktop_file_ = GS_DESKTOP; + EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), GS_DESKTOP); } -TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformAppInstall) -{ - // ensure that tranformation from app-install data desktop files works - usc->desktop_file_ = "/usr/share/app-install/desktop/pkgname:kde4__afile.desktop"; - EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), - LOCAL_DATA_DIR+"/applications/kde4/afile.desktop"); -} - -TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformSCAgent) -{ - // now simualte data coming from the sc-agent - usc->desktop_file_ = "/tmp/software-center-agent:VP2W9M:ubuntu-software-center.desktop"; - EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), USC_DESKTOP); -} - -// simulate a OnFinished signal from a /usr/share/app-install location -// and ensure that the remote uri is updated from temp location to -// the real location TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedReplacesDesktopFile) { icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); - - EXPECT_EQ(USC_DESKTOP, icon.DesktopFile()); + EXPECT_EQ(GS_DESKTOP, icon.DesktopFile()); } TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesRemoteURI) { icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); - ASSERT_EQ(USC_DESKTOP, icon.DesktopFile()); - EXPECT_EQ(FavoriteStore::URI_PREFIX_APP + USC_DESKTOP, icon.GetRemoteUri()); + ASSERT_EQ(GS_DESKTOP, icon.DesktopFile()); + EXPECT_EQ(FavoriteStore::URI_PREFIX_APP + GS_DESKTOP, icon.GetRemoteUri()); } TEST_F(TestSoftwareCenterLauncherIcon, DisconnectsOldAppSignals) { - ASSERT_FALSE(usc->closed.empty()); + ASSERT_FALSE(gs->closed.empty()); icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); - EXPECT_TRUE(usc->closed.empty()); - EXPECT_TRUE(usc->window_opened.empty()); - EXPECT_TRUE(usc->window_moved.empty()); - EXPECT_TRUE(usc->window_closed.empty()); - EXPECT_TRUE(usc->visible.changed.empty()); - EXPECT_TRUE(usc->active.changed.empty()); - EXPECT_TRUE(usc->running.changed.empty()); - EXPECT_TRUE(usc->urgent.changed.empty()); - EXPECT_TRUE(usc->desktop_file.changed.empty()); - EXPECT_TRUE(usc->title.changed.empty()); - EXPECT_TRUE(usc->icon.changed.empty()); + EXPECT_TRUE(gs->closed.empty()); + EXPECT_TRUE(gs->window_opened.empty()); + EXPECT_TRUE(gs->window_moved.empty()); + EXPECT_TRUE(gs->window_closed.empty()); + EXPECT_TRUE(gs->visible.changed.empty()); + EXPECT_TRUE(gs->active.changed.empty()); + EXPECT_TRUE(gs->running.changed.empty()); + EXPECT_TRUE(gs->urgent.changed.empty()); + EXPECT_TRUE(gs->desktop_file.changed.empty()); + EXPECT_TRUE(gs->title.changed.empty()); + EXPECT_TRUE(gs->icon.changed.empty()); } TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedRemoveInvalidNewAppIcon) { // Using an icon ptr, to get the removed signal to be properly emitted nux::ObjectPtr<MockSoftwareCenterLauncherIcon> icon_ptr( - new MockSoftwareCenterLauncherIcon(usc, "/com/canonical/unity/test/object/path", PRE_INSTALL_ICON)); + new MockSoftwareCenterLauncherIcon(gs, "/com/canonical/unity/test/object/path")); bool removed = false; auto& app_manager = unity::ApplicationManager::Default(); @@ -201,7 +177,7 @@ TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedKeepsStickyStatus) icon.LauncherIconUnstick(); bool saved = false; - usc->sticky = true; + gs->sticky = true; icon.position_saved.connect([&saved] {saved = true;}); ASSERT_FALSE(icon.IsSticky()); @@ -214,14 +190,7 @@ TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesTooltip) { icon.tooltip_text = "FooText"; icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); - EXPECT_EQ(icon.tooltip_text(), usc->title()); -} - -TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesIcon) -{ - icon.icon_name = "foo-icon"; - icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); - EXPECT_EQ(icon.icon_name(), usc->icon()); + EXPECT_EQ(icon.tooltip_text(), gs->title()); } TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedLogsEvent) @@ -230,52 +199,9 @@ TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedLogsEvent) icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); } -TEST_F(TestSoftwareCenterLauncherIcon, AnimateToInvalidPosition) -{ - EXPECT_FALSE(icon.Animate(CreateLauncher(), 1, 2)); - EXPECT_FALSE(icon.IsVisible()); - EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name()); -} - -TEST_F(TestSoftwareCenterLauncherIcon, AnimateFromInvalidPosition) -{ - EXPECT_TRUE(icon.Animate(CreateLauncher(), 0, 0)); - EXPECT_TRUE(icon.IsVisible()); - EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name()); -} - #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-variable" -struct MultiMonitor : TestSoftwareCenterLauncherIcon, WithParamInterface<unsigned> {}; -INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, MultiMonitor, Range<unsigned>(0, monitors::MAX, 1)); - -TEST_P(/*TestSoftwareCenterLauncherIcon*/MultiMonitor, Animate) -{ - auto launcher = CreateLauncher(); - launcher->monitor = GetParam(); - icon.SetCenter({1, 1, 0}, launcher->monitor()); - ASSERT_TRUE(icon.Animate(launcher, 2, 2)); - EXPECT_FALSE(icon.IsVisible()); - EXPECT_TRUE(icon.icon_name().empty()); - - for (unsigned i = 0; i < monitors::MAX; ++i) - ASSERT_EQ(static_cast<int>(i) == launcher->monitor(), icon.IsVisibleOnMonitor(i)); - - bool animated = false; - ASSERT_TRUE(icon.drag_window_); - icon.drag_window_->anim_completed.connect([&animated] { animated = true; }); - Utils::WaitUntilMSec(animated); - ASSERT_TRUE(animated); - - EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name()); - EXPECT_FALSE(icon.drag_window_); - - for (unsigned i = 0; i < monitors::MAX; ++i) - ASSERT_TRUE(icon.IsVisibleOnMonitor(i)); - - EXPECT_TRUE(icon.IsVisible()); -} struct InstallProgress : TestSoftwareCenterLauncherIcon, WithParamInterface<int> {}; INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, InstallProgress, Range<int>(0, 99, 10)); |
