Bug 1798238 - move dump_view_state and friends to FolderDisplayHelpers.jsm. r=aleca
Differential Revision: https://phabricator.services.mozilla.com/D161115 --HG-- extra : rebase_source : 43be1296227fd9ca9bd7e9911a46d56f036400ab
This commit is contained in:
Родитель
23ce3ccc12
Коммит
cf974acdbc
|
@ -18,6 +18,10 @@ var { MessageInjection } = ChromeUtils.import(
|
|||
"resource://testing-common/mailnews/MessageInjection.jsm"
|
||||
);
|
||||
|
||||
var { dump_view_state } = ChromeUtils.import(
|
||||
"resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
|
||||
);
|
||||
|
||||
var gMessageGenerator;
|
||||
var gMessageScenarioFactory;
|
||||
var messageInjection;
|
||||
|
@ -304,85 +308,6 @@ function dump_message_header(aMsgHdr) {
|
|||
);
|
||||
}
|
||||
|
||||
var WHITESPACE = " ";
|
||||
var MSG_VIEW_FLAG_DUMMY = 0x20000000;
|
||||
function dump_view_contents(aViewWrapper) {
|
||||
let dbView = aViewWrapper.dbView;
|
||||
let treeView = aViewWrapper.dbView.QueryInterface(Ci.nsITreeView);
|
||||
let rowCount = treeView.rowCount;
|
||||
|
||||
dump("********* Current View Contents\n");
|
||||
for (let iViewIndex = 0; iViewIndex < rowCount; iViewIndex++) {
|
||||
let level = treeView.getLevel(iViewIndex);
|
||||
let flags = dbView.getFlagsAt(iViewIndex);
|
||||
let msgHdr = dbView.getMsgHdrAt(iViewIndex);
|
||||
|
||||
let s = WHITESPACE.substr(0, level * 2);
|
||||
if (treeView.isContainer(iViewIndex)) {
|
||||
s += treeView.isContainerOpen(iViewIndex) ? "- " : "+ ";
|
||||
} else {
|
||||
s += ". ";
|
||||
}
|
||||
// s += treeView.getCellText(iViewIndex, )
|
||||
if (flags & MSG_VIEW_FLAG_DUMMY) {
|
||||
s += "dummy: ";
|
||||
}
|
||||
s += dbView.cellTextForColumn(iViewIndex, "subject");
|
||||
s += " [" + msgHdr.folder.prettyName + "," + msgHdr.messageKey + "]";
|
||||
|
||||
dump(s + "\n");
|
||||
}
|
||||
dump("********* end view contents\n");
|
||||
}
|
||||
|
||||
function _lookupValueNameInInterface(aValue, aInterface) {
|
||||
for (let key in aInterface) {
|
||||
let value = aInterface[key];
|
||||
if (value == aValue) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
return "unknown: " + aValue;
|
||||
}
|
||||
|
||||
function dump_view_state(aViewWrapper, aDoNotDumpContents) {
|
||||
if (aViewWrapper.dbView == null) {
|
||||
dump("no nsIMsgDBView instance!\n");
|
||||
return;
|
||||
}
|
||||
if (!aDoNotDumpContents) {
|
||||
dump_view_contents(aViewWrapper);
|
||||
}
|
||||
dump("View: " + aViewWrapper.dbView + "\n");
|
||||
dump(
|
||||
" View Type: " +
|
||||
_lookupValueNameInInterface(
|
||||
aViewWrapper.dbView.viewType,
|
||||
Ci.nsMsgViewType
|
||||
) +
|
||||
" " +
|
||||
"View Flags: " +
|
||||
aViewWrapper.dbView.viewFlags +
|
||||
"\n"
|
||||
);
|
||||
dump(
|
||||
" Sort Type: " +
|
||||
_lookupValueNameInInterface(
|
||||
aViewWrapper.dbView.sortType,
|
||||
Ci.nsMsgViewSortType
|
||||
) +
|
||||
" " +
|
||||
"Sort Order: " +
|
||||
_lookupValueNameInInterface(
|
||||
aViewWrapper.dbView.sortOrder,
|
||||
Ci.nsMsgViewSortOrder
|
||||
) +
|
||||
"\n"
|
||||
);
|
||||
|
||||
dump(aViewWrapper.search.prettyString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the messages in the provided SyntheticMessageSets are the only
|
||||
* visible messages in the provided DBViewWrapper. If dummy headers are present
|
||||
|
@ -528,6 +453,7 @@ function verify_view_row_at_index_is_container(aViewWrapper, ...aArgs) {
|
|||
* @param ... View indices to check.
|
||||
*/
|
||||
function verify_view_row_at_index_is_dummy(aViewWrapper, ...aArgs) {
|
||||
const MSG_VIEW_FLAG_DUMMY = 0x20000000;
|
||||
for (let viewIndex of aArgs) {
|
||||
let flags = aViewWrapper.dbView.getFlagsAt(viewIndex);
|
||||
if (!(flags & MSG_VIEW_FLAG_DUMMY)) {
|
||||
|
|
|
@ -72,6 +72,8 @@ const EXPORTED_SYMBOLS = [
|
|||
"delete_messages",
|
||||
"delete_via_popup",
|
||||
"display_message_in_folder_tab",
|
||||
"dump_view_contents",
|
||||
"dump_view_state",
|
||||
"empty_folder",
|
||||
"enter_folder",
|
||||
"expand_all_threads",
|
||||
|
@ -3317,7 +3319,7 @@ function throw_and_dump_view_state(aMessage, aController) {
|
|||
}
|
||||
|
||||
dump("******** " + aMessage + "\n");
|
||||
testHelperModule.dump_view_state(aController.folderDisplay.view);
|
||||
dump_view_state(aController.folderDisplay.view);
|
||||
throw new Error(aMessage);
|
||||
}
|
||||
|
||||
|
@ -3428,3 +3430,81 @@ function load_via_src_path(aPath, aScope) {
|
|||
let uri = Services.io.newFileURI(file).spec;
|
||||
Services.scriptloader.loadSubScript(uri, aScope);
|
||||
}
|
||||
|
||||
function dump_view_state(aViewWrapper, aDoNotDumpContents) {
|
||||
if (aViewWrapper.dbView == null) {
|
||||
dump("no nsIMsgDBView instance!\n");
|
||||
return;
|
||||
}
|
||||
if (!aDoNotDumpContents) {
|
||||
dump_view_contents(aViewWrapper);
|
||||
}
|
||||
dump("View: " + aViewWrapper.dbView + "\n");
|
||||
dump(
|
||||
" View Type: " +
|
||||
_lookupValueNameInInterface(
|
||||
aViewWrapper.dbView.viewType,
|
||||
Ci.nsMsgViewType
|
||||
) +
|
||||
" " +
|
||||
"View Flags: " +
|
||||
aViewWrapper.dbView.viewFlags +
|
||||
"\n"
|
||||
);
|
||||
dump(
|
||||
" Sort Type: " +
|
||||
_lookupValueNameInInterface(
|
||||
aViewWrapper.dbView.sortType,
|
||||
Ci.nsMsgViewSortType
|
||||
) +
|
||||
" " +
|
||||
"Sort Order: " +
|
||||
_lookupValueNameInInterface(
|
||||
aViewWrapper.dbView.sortOrder,
|
||||
Ci.nsMsgViewSortOrder
|
||||
) +
|
||||
"\n"
|
||||
);
|
||||
dump(aViewWrapper.search.prettyString());
|
||||
}
|
||||
|
||||
var WHITESPACE = " ";
|
||||
var MSG_VIEW_FLAG_DUMMY = 0x20000000;
|
||||
function dump_view_contents(aViewWrapper) {
|
||||
let dbView = aViewWrapper.dbView;
|
||||
let treeView = aViewWrapper.dbView.QueryInterface(Ci.nsITreeView);
|
||||
let rowCount = treeView.rowCount;
|
||||
|
||||
dump("********* Current View Contents\n");
|
||||
for (let iViewIndex = 0; iViewIndex < rowCount; iViewIndex++) {
|
||||
let level = treeView.getLevel(iViewIndex);
|
||||
let flags = dbView.getFlagsAt(iViewIndex);
|
||||
let msgHdr = dbView.getMsgHdrAt(iViewIndex);
|
||||
|
||||
let s = WHITESPACE.substr(0, level * 2);
|
||||
if (treeView.isContainer(iViewIndex)) {
|
||||
s += treeView.isContainerOpen(iViewIndex) ? "- " : "+ ";
|
||||
} else {
|
||||
s += ". ";
|
||||
}
|
||||
// s += treeView.getCellText(iViewIndex, )
|
||||
if (flags & MSG_VIEW_FLAG_DUMMY) {
|
||||
s += "dummy: ";
|
||||
}
|
||||
s += dbView.cellTextForColumn(iViewIndex, "subject");
|
||||
s += " [" + msgHdr.folder.prettyName + "," + msgHdr.messageKey + "]";
|
||||
|
||||
dump(s + "\n");
|
||||
}
|
||||
dump("********* end view contents\n");
|
||||
}
|
||||
|
||||
function _lookupValueNameInInterface(aValue, aInterface) {
|
||||
for (let key in aInterface) {
|
||||
let value = aInterface[key];
|
||||
if (value == aValue) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
return "unknown: " + aValue;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,9 @@ var { MessageInjection } = ChromeUtils.import(
|
|||
var { PromiseUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/PromiseUtils.sys.mjs"
|
||||
);
|
||||
var { dump_view_contents } = ChromeUtils.import(
|
||||
"resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
|
||||
);
|
||||
|
||||
// Items used to add messages to the folder
|
||||
var gMessageGenerator = new MessageGenerator();
|
||||
|
@ -103,31 +106,6 @@ async function make_and_add_message(aMessageArgs) {
|
|||
return [synMsg, msgSet];
|
||||
}
|
||||
|
||||
var WHITESPACE = " ";
|
||||
/**
|
||||
* Print out the current db view as best we can.
|
||||
*/
|
||||
function dump_view_contents() {
|
||||
dump("********* Current View State\n");
|
||||
for (let iViewIndex = 0; iViewIndex < gTreeView.rowCount; iViewIndex++) {
|
||||
let level = gTreeView.getLevel(iViewIndex);
|
||||
let flags = gDBView.getFlagsAt(iViewIndex);
|
||||
|
||||
let s = WHITESPACE.substr(0, level * 2);
|
||||
if (gTreeView.isContainer(iViewIndex)) {
|
||||
s += gTreeView.isContainerOpen(iViewIndex) ? "- " : "+ ";
|
||||
} else {
|
||||
s += ". ";
|
||||
}
|
||||
if (flags & MSG_VIEW_FLAG_DUMMY) {
|
||||
s += "dummy: ";
|
||||
}
|
||||
s += gDBView.cellTextForColumn(iViewIndex, "subject");
|
||||
dump(s + "\n");
|
||||
}
|
||||
dump("********* end view state\n");
|
||||
}
|
||||
|
||||
function view_throw(why) {
|
||||
dump_view_contents();
|
||||
do_throw(why);
|
||||
|
|
|
@ -19,6 +19,10 @@ var { MessageGenerator, SyntheticMessageSet } = ChromeUtils.import(
|
|||
var { MessageInjection } = ChromeUtils.import(
|
||||
"resource://testing-common/mailnews/MessageInjection.jsm"
|
||||
);
|
||||
var { dump_view_contents } = ChromeUtils.import(
|
||||
"resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
|
||||
);
|
||||
|
||||
var gMessageGenerator = new MessageGenerator();
|
||||
var messageInjection = new MessageInjection({ mode: "local" });
|
||||
|
||||
|
@ -105,36 +109,6 @@ add_task(function test_view_sort_by_addresses() {
|
|||
}
|
||||
});
|
||||
|
||||
var WHITESPACE = " ";
|
||||
/**
|
||||
* Print out the current db view as best we can.
|
||||
*/
|
||||
function dump_view_contents() {
|
||||
dump("********* Current View State\n");
|
||||
for (let iViewIndex = 0; iViewIndex < gTreeView.rowCount; iViewIndex++) {
|
||||
let level = gTreeView.getLevel(iViewIndex);
|
||||
let flags = gDBView.getFlagsAt(iViewIndex);
|
||||
|
||||
let s = WHITESPACE.substr(0, level * 2);
|
||||
if (gTreeView.isContainer(iViewIndex)) {
|
||||
s += gTreeView.isContainerOpen(iViewIndex) ? "- " : "+ ";
|
||||
} else {
|
||||
s += ". ";
|
||||
}
|
||||
let MSG_VIEW_FLAG_DUMMY = 0x20000000;
|
||||
if (flags & MSG_VIEW_FLAG_DUMMY) {
|
||||
s += "dummy: ";
|
||||
}
|
||||
s +=
|
||||
gDBView.cellTextForColumn(iViewIndex, "subjectCol") +
|
||||
" " +
|
||||
gDBView.cellTextForColumn(iViewIndex, "senderCol");
|
||||
|
||||
dump(s + "\n");
|
||||
}
|
||||
dump("********* end view state\n");
|
||||
}
|
||||
|
||||
function view_throw(why) {
|
||||
dump_view_contents();
|
||||
do_throw(why);
|
||||
|
|
Загрузка…
Ссылка в новой задаче