Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Unified Diff: ios/chrome/browser/web/mailto_url_rewriter_unittest.mm

Issue 2904663003: Revert to system Mail app if current default Mail app is no longer there (Closed)
Patch Set: clarified a comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/web/mailto_url_rewriter.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/web/mailto_url_rewriter_unittest.mm
diff --git a/ios/chrome/browser/web/mailto_url_rewriter_unittest.mm b/ios/chrome/browser/web/mailto_url_rewriter_unittest.mm
index 7df96bb89e6e745f6ff58106697b2b555c32c063..961a62f65f893ff4760c0560008a288e0670cf2f 100644
--- a/ios/chrome/browser/web/mailto_url_rewriter_unittest.mm
+++ b/ios/chrome/browser/web/mailto_url_rewriter_unittest.mm
@@ -55,11 +55,31 @@ TEST_F(MailtoURLRewriterTest, TestStandardInstance) {
for (MailtoHandler* handler in handlers) {
ASSERT_TRUE(handler);
NSString* appStoreID = [handler appStoreID];
+ NSString* expectedDefaultAppID =
+ [handler isAvailable] ? appStoreID : [MailtoURLRewriter systemMailApp];
[rewriter setDefaultHandlerID:appStoreID];
- EXPECT_NSEQ(appStoreID, [rewriter defaultHandlerID]);
+ EXPECT_NSEQ(expectedDefaultAppID, [rewriter defaultHandlerID]);
}
}
+TEST_F(MailtoURLRewriterTest, TestDefaultsInvalidToSystemMail) {
+ // Sets up a MailtoURLRewriter with 2 MailtoHandler objects:
+ // - system-provided Mail client app
+ // - Gmail app, but it is not installed
+ MailtoURLRewriter* rewriter = [[MailtoURLRewriter alloc] init];
+ MailtoHandler* systemMailHandler = [[MailtoHandlerSystemMail alloc] init];
+ MailtoHandler* fakeGmailHandler =
+ [[FakeMailtoHandlerGmailNotInstalled alloc] init];
+ [rewriter addMailtoApps:@[ systemMailHandler, fakeGmailHandler ]];
+ // Sets the default handler to Gmail (which is not installed). This simulates
+ // the situation when Gmail was installed and set as the default handler.
+ // Then Gmail app is deleted from the device.
+ [rewriter setDefaultHandlerID:[fakeGmailHandler appStoreID]];
+ // Verifies that the system-provided Mail app automatically assumes the
+ // default handler.
+ EXPECT_NSEQ([MailtoURLRewriter systemMailApp], [rewriter defaultHandlerID]);
+}
+
TEST_F(MailtoURLRewriterTest, TestUserPreferencePersistence) {
// Sets up a first MailtoURLRewriter with at least 2 MailtoHandler objects.
// A faked Gmail handler that is installed must be used or -addMailtoApp:
« no previous file with comments | « ios/chrome/browser/web/mailto_url_rewriter.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698