• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (C) 2011 The Android Open Source Project.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * You can run this entire test case with:
18  *   runtest -c com.android.exchange.adapter.AttachmentLoaderTests exchange
19  */
20 package com.android.exchange.adapter;
21 
22 import android.test.AndroidTestCase;
23 import android.test.suitebuilder.annotation.SmallTest;
24 
25 @SmallTest
26 public class AttachmentLoaderTests extends AndroidTestCase {
27     private static final String TEST_LOCATION =
28         "Inbox/FW:%204G%20Netbook%20|%20Now%20Available%20for%20Order.EML/image012.jpg";
29 
testEncodeForExchange2003()30     public void testEncodeForExchange2003() {
31         assertEquals("abc", AttachmentLoader.encodeForExchange2003("abc"));
32         // We don't encode the four characters after abc
33         assertEquals("abc_:/.", AttachmentLoader.encodeForExchange2003("abc_:/."));
34         // We don't re-encode escaped characters
35         assertEquals("%20%33", AttachmentLoader.encodeForExchange2003("%20%33"));
36         // Test with the location that failed in use
37         assertEquals(TEST_LOCATION.replace("|", "%7C"),
38                 AttachmentLoader.encodeForExchange2003(TEST_LOCATION));
39     }
40 }
41