Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #17317 from ankit93040/943976_SMS/MMS__Attaching_V…
Browse files Browse the repository at this point in the history
…ideo_MMS_Prompts_Wrong_Error_Message

Bug 943976: Attaching_Video_MMS_Prompts_Wrong_Error_Message, r=schung
  • Loading branch information
steveck-chung committed Mar 19, 2014
2 parents 077d32a + 46671d6 commit 16b7f7c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
4 changes: 4 additions & 0 deletions apps/sms/js/activity_handler.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ var ActivityHandler = {
// TODO: We only allow sharing one item in a single action now.
// Keeping the same sequence while adding the multiple items
// should be considered in the future.
if (attachment.size > Settings.mmsSizeLimitation) {
alert(navigator.mozL10n.get('file-too-large'));
return;
}
Compose.append(attachment);
});
}
Expand Down
2 changes: 1 addition & 1 deletion apps/sms/js/thread_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ var ThreadUI = global.ThreadUI = {
if (Settings.mmsSizeLimitation) {
if (Compose.size > Settings.mmsSizeLimitation) {
Compose.lock = true;
this.showMaxLengthNotice('messages-exceeded-length-text');
this.showMaxLengthNotice('message-exceeded-max-length');
return false;
} else if (Compose.size === Settings.mmsSizeLimitation) {
Compose.lock = true;
Expand Down
2 changes: 1 addition & 1 deletion apps/sms/locales/sms.en-US.properties
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ converted-to-mms = Converting to multimedia message.
converted-to-sms = Converting to text message.
messages-max-length-text = You’ve reached the maximum length.
messages-max-subject-length-text = Maximum length of subject reached.
messages-exceeded-length-text = Youve exceeded the maximum length. Remove special characters or shorten the message to send it.
message-exceeded-max-length = You've exceeded the maximum size. Remove attachments or shorten the message to send it.
newMessage = New message
sendMessage = Send message
no-recipient = (No recipient)
Expand Down
20 changes: 16 additions & 4 deletions apps/sms/test/unit/activity_handler_test.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*global Notify, Compose, mocha, MocksHelper, ActivityHandler, Contacts,
MessageManager, Attachment, ThreadUI */
MessageManager, Attachment, ThreadUI, Settings */
/*global MockNavigatormozSetMessageHandler, MockNavigatormozApps,
MockNavigatorWakeLock, MockOptionMenu, Mockalert,
MockMessages, MockNavigatorSettings, MockL10n,
Expand Down Expand Up @@ -120,17 +120,18 @@ suite('ActivityHandler', function() {
source: {
name: 'share',
data: {
blobs: [new Blob(), new Blob()],
blobs: [
new Blob(['test'], { type: 'text/plain' }),
new Blob(['string'], { type: 'text/plain' })
],
filenames: ['testBlob1', 'testBlob2']
}
}
};
this.prevAppend = Compose.append;
});

teardown(function() {
window.location.hash = this.prevHash;
Compose.append = this.prevAppend;
});

test('modifies the URL "hash" when necessary', function() {
Expand All @@ -145,6 +146,7 @@ suite('ActivityHandler', function() {

assert.instanceOf(attachment, Attachment);
assert.ok(Compose.append.callCount < 3);
assert.equal(Mockalert.mLastMessage, null);

if (Compose.append.callCount === 2) {
done();
Expand All @@ -153,7 +155,17 @@ suite('ActivityHandler', function() {

MockNavigatormozSetMessageHandler.mTrigger('activity', shareActivity);
});
test('Attachment size over max mms should not be appended', function() {
// Adjust mmsSizeLimitation for verifying alert popup when size over
// limitation
Settings.mmsSizeLimitation = 1;
this.sinon.spy(Compose, 'append');
window.location.hash = '#new';

MockNavigatormozSetMessageHandler.mTrigger('activity', shareActivity);
sinon.assert.notCalled(Compose.append);
assert.equal(Mockalert.mLastMessage, 'file-too-large');
});
test('share shouldn\'t change the ThreadUI back button', function() {
this.sinon.stub(ThreadUI, 'enableActivityRequestMode');
MockNavigatormozSetMessageHandler.mTrigger('activity', shareActivity);
Expand Down
2 changes: 1 addition & 1 deletion apps/sms/test/unit/thread_ui_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ suite('thread_ui.js >', function() {
test('banner localized', function() {
assert.ok(
localize.calledWith(banner.querySelector('p'),
'messages-exceeded-length-text')
'message-exceeded-max-length')
);
});

Expand Down

0 comments on commit 16b7f7c

Please sign in to comment.