Bug 1798238 - move dump_view_state and friends to ViewHelpers.jsm. r=aleca
Differential Revision: https://phabricator.services.mozilla.com/D161115 --HG-- extra : rebase_source : 3e5bf90a0969325009145f359fd0dfa0309eacab extra : amend_source : 2011d81d913c4f337e2bd2b87aa1c28d0841df48
This commit is contained in:
Родитель
08f0221750
Коммит
29a4263ac8
|
@ -17,6 +17,9 @@ var { MessageGenerator, MessageScenarioFactory } = ChromeUtils.import(
|
|||
var { MessageInjection } = ChromeUtils.import(
|
||||
"resource://testing-common/mailnews/MessageInjection.jsm"
|
||||
);
|
||||
var { dump_view_state } = ChromeUtils.import(
|
||||
"resource://testing-common/mozmill/ViewHelpers.jsm"
|
||||
);
|
||||
|
||||
var gMessageGenerator;
|
||||
var gMessageScenarioFactory;
|
||||
|
@ -304,85 +307,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 +452,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)) {
|
||||
|
|
|
@ -185,6 +185,9 @@ var { MessageInjection } = ChromeUtils.import(
|
|||
var { SmimeUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/mailnews/smimeUtils.jsm"
|
||||
);
|
||||
var { dump_view_state } = ChromeUtils.import(
|
||||
"resource://testing-common/mozmill/ViewHelpers.jsm"
|
||||
);
|
||||
|
||||
/**
|
||||
* Server hostname as set in runtest.py
|
||||
|
@ -3317,7 +3320,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);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/** Module to help debugging view wrapper issues. */
|
||||
|
||||
const EXPORTED_SYMBOLS = ["dump_view_contents", "dump_view_state"];
|
||||
|
||||
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,5 +29,6 @@ TESTING_JS_MODULES.mozmill += [
|
|||
"SearchWindowHelpers.jsm",
|
||||
"SubscribeWindowHelpers.jsm",
|
||||
"utils.jsm",
|
||||
"ViewHelpers.jsm",
|
||||
"WindowHelpers.jsm",
|
||||
]
|
||||
|
|
|
@ -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/ViewHelpers.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/ViewHelpers.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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче