From c13fec2ab001d61bed805f3fbbde0c270447e49b Mon Sep 17 00:00:00 2001 From: Andrew Sutherland Date: Wed, 9 Sep 2009 17:27:08 -0700 Subject: [PATCH] passes quick search unit test now. --HG-- branch : gloda-facet --- mail/base/content/search.xml | 7 +-- mail/build.mk | 4 +- .../folder-display/test-quick-search.js | 12 ++--- mailnews/db/gloda/components/glautocomp.js | 46 ++++++++++--------- 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/mail/base/content/search.xml b/mail/base/content/search.xml index 9d7ad4bbad..57fa21c7ad 100644 --- a/mail/base/content/search.xml +++ b/mail/base/content/search.xml @@ -199,7 +199,7 @@ const Cc = Components.classes; const Ci = Components.interfaces; const Cu = Components.utils; - Cu.import("resource://gre/modules/errUtils.js"); + Cu.import("resource://app/modules/errUtils.js"); try { Cu.import("resource://app/modules/StringBundle.js"); Cu.import("resource://app/modules/quickSearchManager.js"); @@ -262,7 +262,7 @@ quickSearchModes[QuickSearchConstants.kQuickSearchFromOrSubject] .value.toString(); } catch (e) { - logException(e); + logException(e, true); } ]]> @@ -345,7 +345,8 @@ diff --git a/mail/build.mk b/mail/build.mk index 5aa896fda0..86da49d558 100644 --- a/mail/build.mk +++ b/mail/build.mk @@ -122,10 +122,10 @@ mozmill:: cd $(MOZMILLDIR) && MACOSX_DEPLOYMENT_TARGET= $(PYTHON) \ runtestlist.py --list=mozmilltests.list --binary=$(PROGRAM) \ --dir=$(topsrcdir)/mail/test/mozmill \ - --default-profile=$(PROGRAM_LOCATION)/defaults/profile + --default-profile=$(PROGRAM_LOCATION)/defaults/profile $(MOZMILL_EXTRA) mozmill-one:: cd $(MOZMILLDIR) && MACOSX_DEPLOYMENT_TARGET= $(PYTHON) runtest.py \ --test=$(topsrcdir)/mail/test/mozmill/$(SOLO_TEST) --binary=$(PROGRAM) \ - --default-profile=$(PROGRAM_LOCATION)/defaults/profile + --default-profile=$(PROGRAM_LOCATION)/defaults/profile $(MOZMILL_EXTRA) endif diff --git a/mail/test/mozmill/folder-display/test-quick-search.js b/mail/test/mozmill/folder-display/test-quick-search.js index e0003b8915..b7198c8e12 100644 --- a/mail/test/mozmill/folder-display/test-quick-search.js +++ b/mail/test/mozmill/folder-display/test-quick-search.js @@ -61,15 +61,11 @@ function setupModule(module) { * */ function test_save_quick_search() { - mc.sleep(3000); be_in_folder(folder); - mc.sleep(2000); - // - Force it to do a subject search, not a gloda search! -dump("GLODA SEARCH MODE: " + mc.e("gloda-search").searchMode + "\n"); - mc.e("gloda-search").searchMode = - QuickSearchConstants.kQuickSearchSubject.toString(); -dump("GLODA SEARCH MODE: " + mc.e("gloda-search").searchMode + "\n"); + // - We want to do a from or subject search + mc.e("searchInput").searchMode = + QuickSearchConstants.kQuickSearchFromOrSubject.toString(); // - Type something in the quick search box. mc.type(mc.eid("searchInput"), "foo"); @@ -83,7 +79,7 @@ dump("GLODA SEARCH MODE: " + mc.e("gloda-search").searchMode + "\n"); // no windowtype, id: "virtualFolderPropertiesDialog") plan_for_modal_dialog("mailnews:virtualFolderProperties", subtest_save_search); - mc.click(mc.eid("quickSearchSaveAsVirtualFolder")); + mc.e("searchInput").saveAsVirtualFolder.doCommand(); wait_for_modal_dialog("mailnews:virtualFolderProperties"); } diff --git a/mailnews/db/gloda/components/glautocomp.js b/mailnews/db/gloda/components/glautocomp.js index 4fbdde0261..86a97b8a27 100644 --- a/mailnews/db/gloda/components/glautocomp.js +++ b/mailnews/db/gloda/components/glautocomp.js @@ -109,7 +109,7 @@ function nsAutoCompleteGlodaResult(aListener, aCompleter, aString) { this._results = []; this._pendingCount = 0; this._problem = false; - + this.wrappedJSObject = this; } nsAutoCompleteGlodaResult.prototype = { @@ -127,7 +127,7 @@ nsAutoCompleteGlodaResult.prototype = { addRows: function ACGR_addRows(aRows) { if (!aRows.length) return; - this._results.push.apply(this._results, aRows); + this._results.push.apply(this._results, aRows); this.listener.onSearchResult(this.completer, this); }, // ==== nsIAutoCompleteResult @@ -236,7 +236,7 @@ ContactIdentityCompleter.prototype = { // - match against database contacts / identities let pending = {contactToThing: contactToThing, pendingCount: 2}; - + let contactQuery = Gloda.newQuery(Gloda.NOUN_CONTACT); contactQuery.nameLike(contactQuery.WILD, aString, contactQuery.WILD); pending.contactColl = contactQuery.getCollection(this, aResult); @@ -247,7 +247,7 @@ ContactIdentityCompleter.prototype = { identityQuery.WILD); pending.identityColl = identityQuery.getCollection(this, aResult); pending.identityColl.becomeExplicit(); - + aResult._contactCompleterPending = pending; return true; @@ -264,7 +264,7 @@ ContactIdentityCompleter.prototype = { // cheat and explicitly add our own contact... if (!(Gloda.myContact.id in this.contactCollection._idMap)) this.contactCollection._onItemsAdded([Gloda.myContact]); - + // the set of identities owned by the contacts is automatically loaded as part // of the contact loading... // (but only if we actually have any contacts) @@ -289,21 +289,21 @@ ContactIdentityCompleter.prototype = { this.suffixTree = new MultiSuffixTree(contactNames.concat(identityMails), this.contactCollection.items.concat(this.identityCollection && this.identityCollection.items)); - + return; } - + // handle the completion case let result = aCollection.data; let pending = result._contactCompleterPending; - + if (--pending.pendingCount == 0) { let possibleDudes = []; - + let contactToThing = pending.contactToThing; - + let items; - + // check identities first because they are better than contacts in terms // of display items = pending.identityColl.items; @@ -324,14 +324,14 @@ ContactIdentityCompleter.prototype = { possibleDudes.push(contact.identities[0]); } } - + // sort in order of descending popularity possibleDudes.sort(this._popularitySorter); let rows = [new ResultRowSingle(dude, "text", result.searchString) for each ([iDude, dude] in Iterator(possibleDudes))]; result.addRows(rows); result.markCompleted(this); - + // the collections no longer care about the result, make it clear. delete pending.identityColl.data; delete pending.contactColl.data; @@ -366,10 +366,10 @@ ContactTagCompleter.prototype = { // now is not the best time to do this; have onFreeTagAdded use a timer. if (this._suffixTreeDirty) this._buildSuffixTree(); - + if (aString.length < 2) return false; // no async mechanism that will add new rows - + tags = this._suffixTree.findMatches(aString.toLowerCase()); let rows = []; for each (let [iTag, tag] in Iterator(tags)) { @@ -380,7 +380,7 @@ ContactTagCompleter.prototype = { rows.push(resRow); } aResult.addRows(rows); - + return false; // no async mechanism that will add new rows } }; @@ -406,7 +406,7 @@ MessageTagCompleter.prototype = { complete: function MessageTagCompleter_complete(aResult, aString) { if (aString.length < 2) return false; - + tags = this._suffixTree.findMatches(aString.toLowerCase()); let rows = []; for each (let [, tag] in Iterator(tags)) { @@ -414,7 +414,7 @@ MessageTagCompleter.prototype = { rows.push(resRow); } aResult.addRows(rows); - + return false; // no async mechanism that will add new rows } }; @@ -445,6 +445,8 @@ FullTextCompleter.prototype = { } }; +var LOG; + function nsAutoCompleteGloda() { this.wrappedJSObject = this; try { @@ -453,7 +455,7 @@ function nsAutoCompleteGloda() { let loadNS = {}; Cu.import("resource://app/modules/gloda/public.js", loadNS); Gloda = loadNS.Gloda; - + Cu.import("resource://app/modules/gloda/utils.js", loadNS); GlodaUtils = loadNS.GlodaUtils; Cu.import("resource://app/modules/gloda/suffixtree.js", loadNS); @@ -462,7 +464,7 @@ function nsAutoCompleteGloda() { TagNoun = loadNS.TagNoun; Cu.import("resource://app/modules/gloda/noun_freetag.js", loadNS); FreeTagNoun = loadNS.FreeTagNoun; - + Cu.import("resource://app/modules/gloda/log4moz.js", loadNS); LOG = loadNS["Log4Moz"].repository.getLogger("gloda.autocomp"); } @@ -492,13 +494,13 @@ nsAutoCompleteGloda.prototype = { // save this for hacky access to the search. I somewhat suspect we simply // should not be using the formal autocomplete mechanism at all. this.curResult = result; - + for each (let [iCompleter, completer] in Iterator(this.completers)) { // they will return true if they have something pending. if (completer.complete(result, aString)) result.markPending(completer); } - + aListener.onSearchResult(this, result); } catch (e) { logException(e);