Ejemplo n.º 1
0
        public void Setup()
        {
            var library = new Moq.Mock <CollectionSettings>();

            library.SetupGet(x => x.IsSourceCollection).Returns(false);
            library.SetupGet(x => x.Language2Iso639Code).Returns("en");
            library.SetupGet(x => x.Language1Iso639Code).Returns("xyz");
            library.SetupGet(x => x.XMatterPackName).Returns("Factory");

            ErrorReport.IsOkToInteractWithUser = false;
            _fileLocator = new FileLocator(new string[]
            {
                FileLocator.GetDirectoryDistributedWithApplication("factoryCollections"),
                FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates"),
                FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates", "Basic Book"),
                FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI"),
                FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserui/bookLayout"),
                FileLocator.GetDirectoryDistributedWithApplication("xMatter")
            });
            _starter = new BookStarter(_fileLocator, dir => new BookStorage(dir, _fileLocator, new BookRenamedEvent(), new CollectionSettings()), library.Object);
            _shellCollectionFolder = new TemporaryFolder("BookStarterTests_ShellCollection");
            _libraryFolder         = new TemporaryFolder("BookStarterTests_LibraryCollection");

            Browser.SetUpXulRunner();
        }
Ejemplo n.º 2
0
        private static void SetUpLocalization()
        {
            string installedStringFileFolder = FileLocator.GetDirectoryDistributedWithApplication("localization");
            string targetTmxFilePath         = Path.Combine(GlyssenInfo.kCompany, GlyssenInfo.kProduct);
            string desiredUiLangId           = Settings.Default.UserInterfaceLanguage;

            LocalizationManager = LocalizationManager.Create(desiredUiLangId, GlyssenInfo.kApplicationId, Application.ProductName, Application.ProductVersion,
                                                             installedStringFileFolder, targetTmxFilePath, Resources.glyssenIcon, IssuesEmailAddress, "Glyssen");

            if (string.IsNullOrEmpty(desiredUiLangId))
            {
                if (LocalizationManager.GetUILanguages(true).Count() > 1)
                {
                    using (var dlg = new LanguageChoosingSimpleDialog(Resources.glyssenIcon))
                        if (DialogResult.OK == dlg.ShowDialog())
                        {
                            Analytics.Track("SetUiLanguage", new Dictionary <string, string> {
                                { "uiLanguage", dlg.SelectedLanguage }, { "initialStartup", "true" }
                            });

                            LocalizationManager.SetUILanguage(dlg.SelectedLanguage, true);
                            Settings.Default.UserInterfaceLanguage = dlg.SelectedLanguage;
                        }
                }
            }

            var uiLanguage = LocalizationManager.UILanguageId;

            LocalizationManager.Create(uiLanguage, "Palaso", "Palaso", Application.ProductVersion,
                                       installedStringFileFolder, targetTmxFilePath, Resources.glyssenIcon, IssuesEmailAddress,
                                       "SIL.Windows.Forms.WritingSystems", "SIL.DblBundle", "SIL.Windows.Forms.DblBundle", "SIL.Windows.Forms.Miscellaneous");
        }
        public void CreateBookOnDiskFromTemplate_FromFactoryA5_Validates()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates",
                                                                            "Basic Book");

            _starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path);
        }
Ejemplo n.º 4
0
        public void BringBookUpToDate_ConvertsTagsToJsonWithExpectedDefaults()
        {
            var    storage = GetInitialStorage();
            var    locator = (FileLocator)storage.GetFileLocator();
            string root    = FileLocator.GetDirectoryDistributedWithApplication(BloomFileLocator.BrowserRoot);

            locator.AddPath(root.CombineForPath("bookLayout"));
            var folder   = storage.FolderPath;
            var tagsPath = Path.Combine(folder, "tags.txt");

            File.WriteAllText(tagsPath, "suitableForMakingShells\nexperimental\nfolio\n");
            var collectionSettings =
                new CollectionSettings(new NewCollectionSettings()
            {
                PathToSettingsFile  = CollectionSettings.GetPathForNewSettings(folder, "test"),
                Language1Iso639Code = "xyz",
                Language2Iso639Code = "en",
                Language3Iso639Code = "fr"
            });
            var book = new Bloom.Book.Book(new BookInfo(folder, true), storage, new Mock <ITemplateFinder>().Object,
                                           collectionSettings,
                                           new Mock <PageSelection>().Object, new PageListChangedEvent(), new BookRefreshEvent());

            book.BringBookUpToDate(new NullProgress());

            Assert.That(!File.Exists(tagsPath), "The tags.txt file should have been removed");
            // BL-2163, we are no longer migrating suitableForMakingShells
            Assert.That(storage.MetaData.IsSuitableForMakingShells, Is.False);
            Assert.That(storage.MetaData.IsFolio, Is.True);
            Assert.That(storage.MetaData.IsExperimental, Is.True);
            Assert.That(storage.MetaData.BookletMakingIsAppropriate, Is.True);
            Assert.That(storage.MetaData.AllowUploading, Is.True);
        }
Ejemplo n.º 5
0
        public void Setup()
        {
            var library = new Moq.Mock <CollectionSettings>();

            library.SetupGet(x => x.IsSourceCollection).Returns(false);
            library.SetupGet(x => x.Language2Iso639Code).Returns("en");
            library.SetupGet(x => x.Language1Iso639Code).Returns("xyz");
            library.SetupGet(x => x.XMatterPackName).Returns("Factory");

            ErrorReport.IsOkToInteractWithUser = false;
            _fileLocator = new FileLocator(new string[]
            {
                //FileLocator.GetDirectoryDistributedWithApplication( "factoryCollections"),
                BloomFileLocator.GetFactoryBookTemplateDirectory("Basic Book"),
                BloomFileLocator.GetFactoryBookTemplateDirectory("Wall Calendar"),
                FileLocator.GetDirectoryDistributedWithApplication(BloomFileLocator.BrowserRoot),
                BloomFileLocator.GetBrowserDirectory("bookLayout"),
                BloomFileLocator.GetBrowserDirectory("bookEdit", "css"),
                BloomFileLocator.GetInstalledXMatterDirectory()
            });

            var projectFolder      = new TemporaryFolder("BookStarterTests_ProjectCollection");
            var collectionSettings = new CollectionSettings(Path.Combine(projectFolder.Path, "test.bloomCollection"));

            _starter = new BookStarter(_fileLocator, (dir, forSelectedBook) => new BookStorage(dir, _fileLocator, new BookRenamedEvent(), collectionSettings), library.Object);
            _shellCollectionFolder = new TemporaryFolder("BookStarterTests_ShellCollection");
            _libraryFolder         = new TemporaryFolder("BookStarterTests_LibraryCollection");
        }
Ejemplo n.º 6
0
        public void BringBookUpToDate_MigratesReaderToolsAvailableToToolboxIsOpen()
        {
            var oldMetaData =
                "{\"bookInstanceId\":\"3328aa4a - 2ef3 - 43a8 - a656 - 1d7c6f00444c\",\"folio\":false,\"title\":\"Landscape basic book\",\"baseUrl\":null,\"bookOrder\":null,\"isbn\":\"\",\"bookLineage\":\"056B6F11-4A6C-4942-B2BC-8861E62B03B3\",\"downloadSource\":null,\"license\":\"cc-by\",\"formatVersion\":\"2.0\",\"licenseNotes\":null,\"copyright\":null,\"authors\":null,\"credits\":\"\",\"tags\":[\"<p>\r\n</p>\"],\"pageCount\":0,\"languages\":[],\"langPointers\":null,\"summary\":null,\"allowUploadingToBloomLibrary\":true,\"bookletMakingIsAppropriate\":true,\"uploader\":null,\"tools\":null,\"readerToolsAvailable\":true}";
            var storage = GetInitialStorage();

            // This seems to be needed to let it locate some kind of collection settings.
            var    folder  = storage.FolderPath;
            var    locator = (FileLocator)storage.GetFileLocator();
            string root    = FileLocator.GetDirectoryDistributedWithApplication(BloomFileLocator.BrowserRoot);

            locator.AddPath(root.CombineForPath("bookLayout"));
            var collectionSettings =
                new CollectionSettings(new NewCollectionSettings()
            {
                PathToSettingsFile  = CollectionSettings.GetPathForNewSettings(folder, "test"),
                Language1Iso639Code = "xyz",
                Language2Iso639Code = "en",
                Language3Iso639Code = "fr"
            });
            var book = new Bloom.Book.Book(new BookInfo(folder, true), storage, new Mock <ITemplateFinder>().Object,
                                           collectionSettings,
                                           new Mock <PageSelection>().Object, new PageListChangedEvent(), new BookRefreshEvent());
            var jsonPath = book.BookInfo.MetaDataPath;

            File.WriteAllText(jsonPath, oldMetaData);

            book.BringBookUpToDate(new NullProgress());

            Assert.That(book.BookInfo.ToolboxIsOpen, Is.True);
        }
Ejemplo n.º 7
0
        private BookStorage Get_NotYetConfigured_CalendardBookStorage()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates", "Wall Calendar");
            var path   = GetPathToHtml(_starter.CreateBookOnDiskFromTemplate(source, _libraryFolder.Path));
            var bs     = new BookStorage(Path.GetDirectoryName(path), _fileLocator, new BookRenamedEvent(), new CollectionSettings());

            return(bs);
        }
        public void CreateBookOnDiskFromTemplate_FromBasicBook_BookletMakingIsAppropriateIsTrue()
        {
            var    source         = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates", "Basic Book");
            string bookFolderPath = _starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path);
            var    metadata       = new BookInfo(bookFolderPath, false);

            Assert.IsTrue(metadata.BookletMakingIsAppropriate);
        }
        private static string TryToGetLegacyArtOfReadingImagesPath()
        {
            const string kImages            = "Images";
            var          distributedWithApp = FileLocator.GetDirectoryDistributedWithApplication(true, "Art Of Reading", kImages);

            if (!string.IsNullOrEmpty(distributedWithApp) && Directory.Exists(distributedWithApp))
            {
                return(distributedWithApp);
            }

            //look for it in a hard-coded location
            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                var unixPaths = new[]
                {
                    @"/usr/share/ArtOfReading/images",     // new package location (standard LSB/FHS location)
                    @"/usr/share/SIL/ArtOfReading/images", // old (lost) package location
                    @"/var/share/ArtOfReading/images"      // obsolete test location (?)
                };

                foreach (var path in unixPaths)
                {
                    if (Directory.Exists(path))
                    {
                        return(path);
                    }
                }
            }
            else
            {
                //look for the folder created by the ArtOfReadingFree installer before 3.3, the first version to put it in the ImageCollections folder.
                var aorInstallerTarget =
                    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
                    .CombineForPath("SIL", "Art Of Reading", kImages);

                //the rest of these are for before we had an installer for AOR
                var appData =
                    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
                    .CombineForPath("Art Of Reading", kImages);
                var appDataNoSpace =
                    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
                    .CombineForPath("ArtOfReading", kImages);
                var winPaths = new[]
                {
                    aorInstallerTarget, @"c:\art of reading\images", @"c:/ArtOfReading/images", appData, appDataNoSpace
                };

                foreach (var path in winPaths)
                {
                    if (Directory.Exists(path))
                    {
                        return(path);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 10
0
        public static void Main(string[] rgArgs)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ErrorReport.AddProperty("EmailAddress", "*****@*****.**");
            ErrorReport.AddStandardProperties();
            ExceptionHandler.Init();

            s_loadingWnd = new SmallFadingWnd(Properties.Resources.kstidLoadingProgramMsg);

            PortableSettingsProvider.SettingsFileFolder = App.ProjectFolder;
            PortableSettingsProvider.SettingsFileName   = "PCIEditor.settings";

            string inventoryFilePath =
                FileLocator.GetDirectoryDistributedWithApplication(App.ConfigFolderName);

            // This is the poor man's way of determining whether or not the user has
            // write access to the folder in which the phonetic inventory
            // is stored. I'm sure there is a great class in .Net to use for such a
            // thing, but I couldn't find it in the little bit of digging I did. Sigh!
            string tmpFile = Path.Combine(inventoryFilePath, "!~tmpaccesstest~!");

            try
            {
                File.WriteAllText(tmpFile, string.Empty);
            }
            catch
            {
                string msg = string.Format(Properties.Resources.kstidWriteAccessErrorMsg, inventoryFilePath);
                Utils.MsgBox(msg);
                return;
            }

            File.Delete(tmpFile);

            string inventoryPath = null;

            try
            {
                // Make sure the phonetic inventory file exists.
                inventoryPath = FileLocator.GetFileDistributedWithApplication(App.ConfigFolderName,
                                                                              App.kDefaultInventoryFileName);
            }
            catch
            {
                string filePath = Utils.PrepFilePathForMsgBox(inventoryPath);
                string msg      = string.Format(Properties.Resources.kstidInventoryFileMissing, filePath);
                Utils.MsgBox(msg);
                return;
            }

            var editor = new PCIEditor();

            editor.OpenFile(inventoryPath);
            Application.Run(editor);
        }
Ejemplo n.º 11
0
        private string GetNewVaccinationsBookPath()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Sample Shells",
                                                                            "Vaccinations");

            var path = GetPathToHtml(_starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path));

            return(path);
        }
Ejemplo n.º 12
0
        public void CreateBookOnDiskFromTemplate_FromFactoryA5AndXMatter_CoverTitleIsIntiallyEmpty()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates",
                                                                            "Basic Book");

            var path = GetPathToHtml(_starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path));

            AssertThatXmlIn.HtmlFile(path).HasSpecifiedNumberOfMatchesForXpath("//div[contains(@class, 'cover ')]//div[@lang='xyz' and contains(@data-book, 'bookTitle') and not(text())]", 1);
        }
Ejemplo n.º 13
0
        public void CreateBookOnDiskFromTemplate_OriginalHasISBN_CopyDoesNotHaveISBN()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Sample Shells", "Vaccinations");

            var path = GetPathToHtml(_starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path));

            AssertThatXmlIn.HtmlFile(path).HasNoMatchForXpath("//div[@id='bloomDataDiv' and @data-book='ISBN']");
            AssertThatXmlIn.HtmlFile(path).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='ISBN' and not(text())]", 1);
        }
Ejemplo n.º 14
0
        public void CreateBookOnDiskFromTemplate_FromFactoryVaccinations_CoverHasOneVisibleVernacularTitle()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Sample Shells",
                                                                            "Vaccinations");

            var path = GetPathToHtml(_starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path));

            AssertThatXmlIn.HtmlFile(path).HasSpecifiedNumberOfMatchesForXpath("//div[contains(@class,'cover')]//*[@data-book='bookTitle' and @lang='xyz']", 1);
        }
Ejemplo n.º 15
0
        public void CreateBookOnDiskFromTemplate_FromFactoryVaccinations_DoesNotLoseTokPisinTitle()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Sample Shells",
                                                                            "Vaccinations");

            var path = GetPathToHtml(_starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path));

            AssertThatXmlIn.HtmlFile(path).HasSpecifiedNumberOfMatchesForXpath("//div[@id='bloomDataDiv']/div[@data-book='bookTitle' and @lang='tpi' and text()='Tambu Sut']", 1);
        }
Ejemplo n.º 16
0
        public void CreateBookOnDiskFromTemplate_FromBasicBook_GetsNoDefaultNameMetaElement()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates", "Basic Book");

            string bookFolderPath = _starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path);

            //see  <meta name="defaultNameForDerivedBooks" content="My Book" />
            AssertThatXmlIn.HtmlFile(GetPathToHtml(bookFolderPath)).HasSpecifiedNumberOfMatchesForXpath("//meta[@name='defaultNameForDerivedBooks']", 0);
        }
Ejemplo n.º 17
0
        public void Setup()
        {
            Palaso.Reporting.ErrorReport.IsOkToInteractWithUser = false;
            _folder = new TemporaryFolder("BookCollectionTests");
//			_fileLocator = new BloomFileLocator(new CollectionSettings(), new XMatterPackFinder(new string[]{}), new string[] { FileLocator.GetDirectoryDistributedWithApplication("root"), FileLocator.GetDirectoryDistributedWithApplication("factoryCollections") });
            _fileLocator = new FileLocator(new string[] { FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI"), FileLocator.GetDirectoryDistributedWithApplication("browserui/bookCss"), FileLocator.GetDirectoryDistributedWithApplication("factoryCollections") });

            _collection = new BookCollection(_folder.Path, BookCollection.CollectionType.TheOneEditableCollection, new BookSelection());
        }
Ejemplo n.º 18
0
        public static void SetUpLocalization()
        {
            var installedStringFileFolder = FileLocator.GetDirectoryDistributedWithApplication("localization");

            try
            {
                _applicationContainer.LocalizationManager = LocalizationManager.Create(Settings.Default.UserInterfaceLanguage,
                                                                                       "Bloom", "Bloom", Application.ProductVersion,
                                                                                       installedStringFileFolder,
                                                                                       "SIL/Bloom",
                                                                                       Resources.Bloom, "*****@*****.**",
                                                                                       //the parameters that follow are namespace beginnings:
                                                                                       "Bloom");

                //We had a case where someone translated stuff into another language, and sent in their tmx. But their tmx had soaked up a bunch of string
                //from their various templates, which were not Bloom standard templates. So then someone else sitting down to localize bloom would be
                //faced with a bunch of string that made no sense to them, because they don't have those templates.
                //So for now, we only soak up new strings if it's a developer, and hope that the Commit process will be enough for them to realize "oh no, I
                //don't want to check that stuff in".

#if DEBUG
                _applicationContainer.LocalizationManager.CollectUpNewStringsDiscoveredDynamically = true;
#else
                _applicationContainer.LocalizationManager.CollectUpNewStringsDiscoveredDynamically = false;
#endif

                var uiLanguage           = LocalizationManager.UILanguageId;        //just feeding this into subsequent creates prevents asking the user twice if the language of their os isn't one we have a tmx for
                var unusedGoesIntoStatic = LocalizationManager.Create(uiLanguage,
                                                                      "Palaso", "Palaso", /*review: this is just bloom's version*/ Application.ProductVersion,
                                                                      installedStringFileFolder,
                                                                      "SIL/Bloom",
                                                                      Resources.Bloom, "*****@*****.**", "Palaso.UI");

                Settings.Default.UserInterfaceLanguage = LocalizationManager.UILanguageId;
            }
            catch (Exception error)
            {
                //handle http://jira.palaso.org/issues/browse/BL-213
                if (Process.GetProcesses().Count(p => p.ProcessName.ToLower().Contains("bloom")) > 1)
                {
                    ErrorReport.NotifyUserOfProblem("Whoops. There is another copy of Bloom already running while Bloom was trying to set up L10NSharp.");
                    Environment.FailFast("Bloom couldn't set up localization");
                }

                if (error.Message.Contains("Bloom.en.tmx"))
                {
                    ErrorReport.NotifyUserOfProblem(error,
                                                    "Sorry. Bloom is trying to set up your machine to use this new version, but something went wrong getting at the file it needs. If you restart your computer, all will be well.");

                    Environment.FailFast("Bloom couldn't set up localization");
                }

                //otherwise, we don't know what caused it.
                throw;
            }
        }
Ejemplo n.º 19
0
        public void CreateBookOnDiskFromTemplate_FromFactoryBasicBook_CreatesWithCorrectStylesheets()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates", "Basic Book");

            var path = GetPathToHtml(_starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path));

            AssertThatXmlIn.HtmlFile(path).HasSpecifiedNumberOfMatchesForXpath("//link[contains(@href, 'Basic Book')]", 1);
            AssertThatXmlIn.HtmlFile(path).HasSpecifiedNumberOfMatchesForXpath("//link[contains(@href, 'preview')]", 1);
            AssertThatXmlIn.HtmlFile(path).HasSpecifiedNumberOfMatchesForXpath("//link[contains(@href, 'basePage')]", 1);
        }
Ejemplo n.º 20
0
        public void CreateBookOnDiskFromTemplate_FromBasicBook_GetsExpectedEnglishTitleInDataDiv()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates", "Basic Book");

            string bookFolderPath = _starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path);
            var    path           = GetPathToHtml(bookFolderPath);

            //see  <meta name="defaultNameForDerivedBooks" content="My Book" />
            AssertThatXmlIn.HtmlFile(path).HasSpecifiedNumberOfMatchesForXpath("//div[@id='bloomDataDiv']/div[@data-book='bookTitle' and @lang='en' and text()='My Book']", 1);
        }
Ejemplo n.º 21
0
        public void CreateBookOnDiskFromTemplate_FromFactoryA5_CreatesWithCoverAndTitle()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates",
                                                                            "Basic Book");

            var path = GetPathToHtml(_starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path));

            AssertThatXmlIn.HtmlFile(path).HasSpecifiedNumberOfMatchesForXpath("//div[contains(@class, 'cover ')]", 4);
            AssertThatXmlIn.HtmlFile(path).HasSpecifiedNumberOfMatchesForXpath("//div[contains(@class, 'titlePage')]", 1);
            AssertThatXmlIn.HtmlFile(path).HasSpecifiedNumberOfMatchesForXpath("//div[contains(@class, 'bloom-page')]", 5);
        }
Ejemplo n.º 22
0
        public void CreateBookOnDiskFromTemplate_FromBasicBook_GetsExpectedFileName()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates", "Basic Book");

            string bookFolderPath = _starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path);
            var    path           = GetPathToHtml(bookFolderPath);

            Assert.AreEqual("My Book.htm", Path.GetFileName(path));
            Assert.IsTrue(Directory.Exists(bookFolderPath));
            Assert.IsTrue(File.Exists(path));
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Give the locations of the bedrock files/folders that come with Bloom. These will have priority.
        /// (But compare GetAfterXMatterFileLocations, for further paths that are searched after factory XMatter).
        /// </summary>
        public static IEnumerable <string> GetFactoryFileLocations()
        {
            //bookLayout has basepage.css. We have it first because it will find its way to many other folders, but this is the authoritative one
            yield return(FileLocator.GetDirectoryDistributedWithApplication(BloomFileLocator.BrowserRoot, "bookLayout"));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(BloomFileLocator.BrowserRoot));

            //hack to get the distfiles folder itself
            yield return(Path.GetDirectoryName(FileLocator.GetDirectoryDistributedWithApplication("localization")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(BloomFileLocator.BrowserRoot));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "bookEdit/js")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "bookEdit/js/toolbar")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "bookEdit/css")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "bookEdit/html")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "bookEdit/html/font-awesome/css")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "bookEdit/img")));

            foreach (var dir in ToolboxView.GetToolboxServerDirectories())
            {
                yield return(dir);
            }
            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "bookEdit/StyleEditor")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "bookEdit/TopicChooser")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "bookPreview")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "collection")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "themes/bloom-jqueryui-theme")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "lib")));

            // not needed: yield return FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot,"lib/localizationManager"));
            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "lib/long-press")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "lib/split-pane")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "lib/ckeditor/skins/icy_orange")));

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "bookEdit/toolbox/talkingBook")));

            yield return(BloomFileLocator.GetInstalledXMatterDirectory());

            yield return(FileLocator.GetDirectoryDistributedWithApplication(Path.Combine(BloomFileLocator.BrowserRoot, "ePUB")));
        }
Ejemplo n.º 24
0
        public void CreateBookOnDiskFromTemplate_FromFactoryVaccinations_InitialFolderNameIsCalledVaccinations()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Sample Shells",
                                                                            "Vaccinations");

            var path = _starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path);

            Assert.AreEqual("Vaccinations", Path.GetFileName(path));

            //NB: although the clas under test here may produce a folder with the right name, the Book class may still mess it up based on variables
            //But that is a different set of unit tests.
        }
Ejemplo n.º 25
0
        private BookStorage Get_NotYetConfigured_CalendardBookStorage()
        {
            var source        = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates", "Wall Calendar");
            var path          = GetPathToHtml(_starter.CreateBookOnDiskFromTemplate(source, _libraryFolder.Path));
            var projectFolder = new TemporaryFolder("ConfiguratorTests_ProjectCollection");
            //review
            var collectionSettings = new CollectionSettings(Path.Combine(projectFolder.Path, "test.bloomCollection"));

            var bs = new BookStorage(Path.GetDirectoryName(path), _fileLocator, new BookRenamedEvent(), collectionSettings);

            return(bs);
        }
Ejemplo n.º 26
0
        public void CreateBookOnDiskFromTemplate_FromBasicBook_BookLineageSetToIdOfSourceBook()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates", "Basic Book");

            string bookFolderPath = _starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path);

            var kIdOfBasicBook = "056B6F11-4A6C-4942-B2BC-8861E62B03B3";

            AssertThatXmlIn.HtmlFile(GetPathToHtml(bookFolderPath)).HasSpecifiedNumberOfMatchesForXpath("//meta[@name='bloomBookLineage' and @content='056B6F11-4A6C-4942-B2BC-8861E62B03B3']", 1);
            //we should get our own id, now reuse our parent's
            AssertThatXmlIn.HtmlFile(GetPathToHtml(bookFolderPath)).HasSpecifiedNumberOfMatchesForXpath("//meta[@name='bloomBookId' and @content='056B6F11-4A6C-4942-B2BC-8861E62B03B3']", 0);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Make the registry entries Bloom requires.
        /// We do this every time a version of Bloom runs, so that if more than one is installed the latest wins.
        /// </summary>
        internal static void MakeBloomRegistryEntries(string[] programArgs)
        {
            if (Program.RunningUnitTests)
            {
                return;                 // unit testing.
            }
            // When installed in program files we only do registry entries when we are first installed,
            // thus keeping them consistent for all users, stored in HKLM.
            if (SharedByAllUsers() && !IsFirstTimeInstall(programArgs))
            {
                return;
            }
            _installInLocalMachine = SharedByAllUsers();
            if (Platform.IsLinux)
            {
                // This will be done by the package installer.
                return;
            }

            var iconDir = FileLocator.GetDirectoryDistributedWithApplication("icons");

            // This is what I (JohnT) think should make Bloom display the right icon for .BloomCollection files.
            EnsureRegistryValue(@".BloomCollection\DefaultIcon", Path.Combine(iconDir, "BloomCollectionIcon.ico"));
            EnsureRegistryValue(@".BloomPack\DefaultIcon", Path.Combine(iconDir, "BloomPack.ico"));

            // These may also be connected with making BloomCollection files display the correct icon.
            // Based on things found in (or done by) the old wix installer.
            EnsureRegistryValue(".BloomCollection", "Bloom.BloomCollectionFile");
            EnsureRegistryValue(".BloomCollectionFile", "Bloom.BloomCollectionFile");
            EnsureRegistryValue("Bloom.BloomCollectionFile", "Bloom Book Collection");
            EnsureRegistryValue(@"Bloom.BloomCollectionFile\DefaultIcon", Path.Combine(iconDir, "BloomCollectionIcon.ico, 0"));

            // I think these help BloomPack files display the correct icon.
            EnsureRegistryValue(".BloomPack", "Bloom.BloomPackFile");
            EnsureRegistryValue("Bloom.BloomPackFile", "Bloom Book Collection");
            EnsureRegistryValue(".BloomPackFile", "Bloom Book Collection");
            EnsureRegistryValue(@"Bloom.BloomPackFile\DefaultIcon", Path.Combine(iconDir, "BloomPack.ico, 0"));
            EnsureRegistryValue(@".BloomPackFile\DefaultIcon", Path.Combine(iconDir, "BloomPack.ico, 0"));
            EnsureRegistryValue(@"SOFTWARE\Classes\Bloom.BloomPack", "Bloom Book Pack", "FriendlyTypeName");

            // This might be part of registering as the executable for various file types?
            // I don't know what does it in wix but it's one of the things the old wix installer created.
            var exe = Assembly.GetExecutingAssembly().Location;

            EnsureRegistryValue(@"bloom\shell\open\command", "\"" + exe + "\" \"%1\"");

            BeTheExecutableFor(".BloomCollection", "BloomCollection file");
            BeTheExecutableFor(".BloomPack", "BloomPack file");
            // Make the OS run Bloom when it sees bloom://somebooktodownload
            BookDownloadSupport.RegisterForBloomUrlProtocol(_installInLocalMachine);
        }
Ejemplo n.º 28
0
        public void Setup()
        {
            _storage = new Moq.Mock <IBookStorage>();
            _storage.Setup(x => x.GetLooksOk()).Returns(true);
            _bookDom = new HtmlDom(GetThreePageDom());
            _storage.SetupGet(x => x.Dom).Returns(() => _bookDom);
            _storage.SetupGet(x => x.Key).Returns("testkey");
            _storage.SetupGet(x => x.FileName).Returns("testTitle");
            _storage.SetupGet(x => x.BookType).Returns(Bloom.Book.Book.BookType.Publication);
            _storage.Setup(x => x.GetRelocatableCopyOfDom(It.IsAny <IProgress>())).Returns(() =>
            {
                return
                (_bookDom.Clone());
            });                                                                  // review: the real thing does more than just clone
            _storage.Setup(x => x.MakeDomRelocatable(It.IsAny <HtmlDom>(), It.IsAny <IProgress>())).Returns(
                (HtmlDom x, IProgress y) => { return(x.Clone()); });             // review: the real thing does more than just clone

            _storage.Setup(x => x.GetFileLocator()).Returns(() => _fileLocator.Object);

            _testFolder = new TemporaryFolder("BookTests");
            _tempFolder = new TemporaryFolder(_testFolder, "book");
            MakeSamplePngImageWithMetadata(Path.Combine(_tempFolder.Path, "original.png"));
            _storage.SetupGet(x => x.FolderPath).Returns(_tempFolder.Path);            // review: the real thing does more than just clone


            _templateFinder = new Moq.Mock <ITemplateFinder>();
            _fileLocator    = new Moq.Mock <IFileLocator>();
            string root               = FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI");
            string xMatter            = FileLocator.GetDirectoryDistributedWithApplication("xMatter");
            string factoryCollections = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections");
            string templates          = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "templates");

            _fileLocator.Setup(x => x.LocateFileWithThrow("languageDisplayTemplate.css")).Returns(root.CombineForPath("bookLayout", "languageDisplayTemplate.css"));
            _fileLocator.Setup(x => x.LocateFileWithThrow("previewMode.css")).Returns("../notareallocation/previewMode.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("editMode.css")).Returns("../notareallocation/editMode.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("editTranslationMode.css")).Returns("../notareallocation/editTranslationMode.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("editOriginalMode.css")).Returns("../notareallocation/editOriginalMode.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("basePage.css")).Returns("../notareallocation/basePage.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("bloomBootstrap.js")).Returns("../notareallocation/bloomBootstrap.js");
            _fileLocator.Setup(x => x.LocateFileWithThrow("bloomPreviewBootstrap.js")).Returns("../notareallocation/bloomPreviewBootstrap.js");
            _fileLocator.Setup(x => x.LocateDirectory("Factory-XMatter")).Returns(xMatter.CombineForPath("Factory-XMatter"));
            _fileLocator.Setup(x => x.LocateDirectory("Factory-XMatter", It.IsAny <string>())).Returns(xMatter.CombineForPath("Factory-XMatter"));
            _fileLocator.Setup(x => x.LocateFileWithThrow("Factory-XMatter".CombineForPath("Factory-XMatter.htm"))).Returns(xMatter.CombineForPath("Factory-XMatter", "Factory-XMatter.htm"));

            //warning: we're neutering part of what the code under test is trying to do here:
            _fileLocator.Setup(x => x.CloneAndCustomize(It.IsAny <IEnumerable <string> >())).Returns(_fileLocator.Object);

            _thumbnailer          = new Moq.Mock <HtmlThumbNailer>(new object[] { 60 });
            _pageSelection        = new Mock <PageSelection>();
            _pageListChangedEvent = new PageListChangedEvent();
        }
Ejemplo n.º 29
0
        public void CreateBookOnDiskFromTemplate_CreationFailsForSomeReason_DoesNotLeaveIncompleteFolderAround()
        {
            var source   = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates", "Basic Book");
            var goodPath = _starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path);

            Directory.Delete(goodPath, true);             //remove that good one. We just did it to get an idea of what the path is

            //now fail while making a book

            _starter.OnNextRunSimulateFailureMakingBook = true;
            Assert.Throws <ApplicationException>(() => _starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path));

            Assert.IsFalse(Directory.Exists(goodPath), "Should not have left the folder there, after a failed book creation");
        }
Ejemplo n.º 30
0
        public void CreateBookOnDiskFromTemplate_FromBasicBook_CreatesCorrectMetaJson()
        {
            var source = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections", "Templates", "Basic Book");

            string bookFolderPath = _starter.CreateBookOnDiskFromTemplate(source, _projectFolder.Path);

            var jsonFile = Path.Combine(bookFolderPath, BookInfo.MetaDataFileName);

            Assert.That(File.Exists(jsonFile), "Creating a book should create a metadata json file meta.json");

            var metadata = new BookInfo(bookFolderPath, false);

            Assert.That(metadata.Id, Is.Not.Null, "New book should get an ID");
        }