diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mail/components/addrbook/test/browser/browser_telemetry.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | comm/mail/components/addrbook/test/browser/browser_telemetry.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/comm/mail/components/addrbook/test/browser/browser_telemetry.js b/comm/mail/components/addrbook/test/browser/browser_telemetry.js new file mode 100644 index 0000000000..36b73207c2 --- /dev/null +++ b/comm/mail/components/addrbook/test/browser/browser_telemetry.js @@ -0,0 +1,59 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Test telemetry related to address book. + */ + +let { MailTelemetryForTests } = ChromeUtils.import( + "resource:///modules/MailGlue.jsm" +); +let { TelemetryTestUtils } = ChromeUtils.importESModule( + "resource://testing-common/TelemetryTestUtils.sys.mjs" +); + +/** + * Test we're counting address books and contacts. + */ +add_task(async function test_address_book_count() { + Services.telemetry.clearScalars(); + + // Adding some address books and contracts. + let addrBook1 = createAddressBook("AB 1"); + let addrBook2 = createAddressBook("AB 2"); + let ldapBook = createAddressBook( + "LDAP Book", + Ci.nsIAbManager.LDAP_DIRECTORY_TYPE + ); + + let contact1 = createContact("test1", "example"); + let contact2 = createContact("test2", "example"); + let contact3 = createContact("test3", "example"); + addrBook1.addCard(contact1); + addrBook2.addCard(contact2); + addrBook2.addCard(contact3); + + // Run the probe. + MailTelemetryForTests.reportAddressBookTypes(); + + let scalars = TelemetryTestUtils.getProcessScalars("parent", true); + Assert.equal( + scalars["tb.addressbook.addressbook_count"]["moz-abldapdirectory"], + 1, + "LDAP address book count must be correct" + ); + Assert.equal( + scalars["tb.addressbook.addressbook_count"].jsaddrbook, + 4, + "JS address book count must be correct" + ); + Assert.equal( + scalars["tb.addressbook.contact_count"].jsaddrbook, + 3, + "Contact count must be correct" + ); + + await promiseDirectoryRemoved(addrBook1.URI); + await promiseDirectoryRemoved(addrBook2.URI); + await promiseDirectoryRemoved(ldapBook.URI); +}); |