コード例 #1
0
    def test_already_existing_file_different_content(self, SettingsMock):
        """A file with a different file content already exists and is updated"""
        SettingsMock.list_schemas.return_value = ["foo", "bar", "baz"]
        result_file = self.write_desktop_file("foo.desktop")
        create_launcher("foo.desktop", self.get_generic_desktop_content())

        self.assertEquals(open(result_file).read(), self.get_generic_desktop_content())
コード例 #2
0
    def test_create_launcher_without_xdg_dir(self, SettingsMock):
        """Save a new launcher in an unexisting directory"""
        shutil.rmtree(self.local_dir)
        SettingsMock.list_schemas.return_value = ["foo", "bar", "baz"]
        create_launcher("foo.desktop", self.get_generic_desktop_content())

        self.assertTrue(os.path.exists(get_launcher_path("foo.desktop")))
コード例 #3
0
 def create_launcher(self):
     """Create the Android Studio launcher"""
     create_launcher(self.desktop_filename, get_application_desktop_file(name=_("Android Studio"),
                     icon_path=os.path.join(self.install_path, "bin", "idea.png"),
                     exec='"{}" %f'.format(os.path.join(self.install_path, "bin", "studio.sh")),
                     comment=_("Android Studio developer environment"),
                     categories="Development;IDE;",
                     extra="StartupWMClass=jetbrains-android-studio"))
コード例 #4
0
    def test_install_no_schema_file(self, SettingsMock):
        """No schema file still installs the file"""
        SettingsMock.list_schemas.return_value = ["foo", "bar", "baz"]
        create_launcher("foo.desktop", self.get_generic_desktop_content())

        self.assertFalse(SettingsMock.return_value.get_strv.called)
        self.assertFalse(SettingsMock.return_value.set_strv.called)
        self.assertTrue(os.path.exists(get_launcher_path("foo.desktop")))
コード例 #5
0
    def test_can_install_already_in_launcher(self, SettingsMock):
        """A file listed in launcher still install the files, but the entry isn't changed"""
        SettingsMock.list_schemas.return_value = ["foo", "bar", "com.canonical.Unity.Launcher", "baz"]
        SettingsMock.return_value.get_strv.return_value = ["application://bar.desktop", "application://foo.desktop",
                                                           "unity://running-apps"]
        create_launcher("foo.desktop", self.get_generic_desktop_content())

        self.assertFalse(SettingsMock.return_value.set_strv.called)
        self.assertTrue(os.path.exists(get_launcher_path("foo.desktop")))
コード例 #6
0
    def test_can_install_without_unity_running(self, SettingsMock):
        """Install a basic launcher icon, without a running apps entry (so will be last)"""
        SettingsMock.list_schemas.return_value = ["foo", "bar", "com.canonical.Unity.Launcher", "baz"]
        SettingsMock.return_value.get_strv.return_value = ["application://bar.desktop", "application://baz.desktop"]
        create_launcher("foo.desktop", self.get_generic_desktop_content())

        self.assertTrue(SettingsMock.list_schemas.called)
        SettingsMock.return_value.set_strv.assert_called_with("favorites", ["application://bar.desktop",
                                                                            "application://baz.desktop",
                                                                            "application://foo.desktop"])
コード例 #7
0
 def create_launcher(self):
     """Create the Android Studio launcher"""
     create_launcher(self.desktop_filename, get_application_desktop_file(name=_("Android Studio"),
                     icon_path=os.path.join(self.install_path, "bin", "idea.png"),
                     exec='"{}" %f'.format(os.path.join(self.install_path, "bin", "studio.sh")),
                     comment=_("Android Studio developer environment"),
                     categories="Development;IDE;",
                     extra="StartupWMClass=jetbrains-android-studio"))
     # add adb and other android tools to PATH
     paths_to_add = [os.path.join(self.install_path, "sdk", "platform-tools"),
                     os.path.join(self.install_path, "sdk", "tools")]
     add_to_user_path(paths_to_add, self.name)
コード例 #8
0
    def test_can_install(self, SettingsMock):
        """Install a basic launcher, default case with unity://running"""
        SettingsMock.list_schemas.return_value = ["foo", "bar", "com.canonical.Unity.Launcher", "baz"]
        SettingsMock.return_value.get_strv.return_value = ["application://bar.desktop", "unity://running-apps"]
        create_launcher("foo.desktop", self.get_generic_desktop_content())

        self.assertTrue(SettingsMock.list_schemas.called)
        SettingsMock.return_value.get_strv.assert_called_with("favorites")
        SettingsMock.return_value.set_strv.assert_called_with("favorites", ["application://bar.desktop",
                                                                            "application://foo.desktop",
                                                                            "unity://running-apps"])
        self.assertTrue(os.path.exists(get_launcher_path("foo.desktop")))
        self.assertEquals(open(get_launcher_path("foo.desktop")).read(), self.get_generic_desktop_content())
コード例 #9
0
 def create_launcher(self):
     """Create the ADT launcher"""
     # copy the adt icon to local folder (as the icon is in a .*version folder, not stable)
     copy_icon(os.path.join(self.install_path,
                            'eclipse/plugins/com.android.ide.eclipse.adt.package*/icons/adt48.png'),
               self.icon_filename)
     create_launcher(self.desktop_filename, get_application_desktop_file(name=_("ADT Eclipse"),
                     icon_path=os.path.splitext(self.icon_filename)[0],
                     exec='"{}" %f'.format(os.path.join(self.install_path, "eclipse", "eclipse")),
                     comment=_("Android Developer Tools (using eclipse)"),
                     categories="Development;IDE;"))
     # add adb and other android tools to PATH
     paths_to_add = [os.path.join(self.install_path, "sdk", "platform-tools"),
                     os.path.join(self.install_path, "sdk", "tools")]
     add_to_user_path(paths_to_add, self.name)
コード例 #10
0
    def test_can_update_launcher(self, SettingsMock):
        """Update a launcher file"""
        SettingsMock.list_schemas.return_value = ["foo", "bar", "com.canonical.Unity.Launcher", "baz"]
        SettingsMock.return_value.get_strv.return_value = ["application://bar.desktop", "unity://running-apps"]
        create_launcher("foo.desktop", self.get_generic_desktop_content())
        new_content = dedent("""\
               [Desktop Entry]
               Version=1.0
               Type=Application
               Name=Android Studio 2
               Icon=/home/didrocks/tools/android-studio/bin/idea2.png
               Exec="/home/didrocks/tools/android-studio/bin/studio2.sh" %f
               Comment=Develop with pleasure!
               Categories=Development;IDE;
               Terminal=false
               StartupWMClass=jetbrains-android-studio
               """)
        create_launcher("foo.desktop", new_content)

        self.assertTrue(os.path.exists(get_launcher_path("foo.desktop")))
        self.assertEquals(open(get_launcher_path("foo.desktop")).read(), new_content)