Merge pull request #1224 from chrox/cover_60

add unit tests for readerdictionary and readerhighlight
This commit is contained in:
HW
2014-11-22 15:30:57 +01:00
4 changed files with 201 additions and 7 deletions

View File

@@ -68,7 +68,7 @@ function ReaderDictionary:stardictLookup(word, box)
--DEBUG("result str:", word, results_str)
local ok, results = pcall(JSON.decode, JSON, results_str)
if ok and results then
DEBUG("lookup result table:", word, results)
--DEBUG("lookup result table:", word, results)
self:showDict(word, tidy_markup(results), box)
else
-- dummy results
@@ -88,7 +88,7 @@ end
function ReaderDictionary:showDict(word, results, box)
if results and results[1] then
DEBUG("showing quick lookup window")
UIManager:show(DictQuickLookup:new{
self.dict_window = DictQuickLookup:new{
ui = self.ui,
highlight = self.highlight,
dialog = self.dialog,
@@ -100,7 +100,8 @@ function ReaderDictionary:showDict(word, results, box)
word_box = box,
-- differentiate between dict and wiki
wiki = self.wiki,
})
}
UIManager:show(self.dict_window)
end
end

View File

@@ -402,12 +402,14 @@ function ReaderHighlight:saveHighlight()
hl_item["datetime"] = os.date("%Y-%m-%d %H:%M:%S")
hl_item["drawer"] = self.view.highlight.saved_drawer
table.insert(self.view.highlight.saved[page], hl_item)
--[[
-- disable exporting hightlights to My Clippings
-- since it's not portable and there is a better Evernote plugin
-- to do the same thing
if self.selected_text.text ~= "" then
-- disable exporting hightlights to My Clippings
-- since it's not potable and there is a better Evernote plugin
-- to do the same thing
--self:exportToClippings(page, hl_item)
self:exportToClippings(page, hl_item)
end
--]]
if self.selected_text.pboxes then
self:exportToDocument(page, hl_item)
end
@@ -415,6 +417,7 @@ function ReaderHighlight:saveHighlight()
--DEBUG("saved hightlights", self.view.highlight.saved[page])
end
--[[
function ReaderHighlight:exportToClippings(page, item)
DEBUG("export highlight to clippings", item)
local clippings = io.open("/mnt/us/documents/My Clippings.txt", "a+")
@@ -431,6 +434,7 @@ function ReaderHighlight:exportToClippings(page, item)
os.setlocale(current_locale)
end
end
--]]
function ReaderHighlight:exportToDocument(page, item)
DEBUG("export highlight to document", item)