• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 // Disabled for now, as these tests will probably not make sense with the upcoming UI change.
18 // TODO Revive them in some way.
19 
20 //package com.android.email.activity;
21 //
22 //import com.android.email.Email;
23 //import com.android.email.MessagingController;
24 //import com.android.email.R;
25 //
26 //import android.app.Application;
27 //import android.content.Context;
28 //import android.content.Intent;
29 //import android.test.ActivityInstrumentationTestCase2;
30 //import android.test.UiThreadTest;
31 //import android.test.suitebuilder.annotation.LargeTest;
32 //import android.test.suitebuilder.annotation.Suppress;
33 //import android.view.View;
34 //import android.webkit.WebView;
35 //import android.widget.TextView;
36 //
37 ///**
38 // * Various instrumentation tests for MessageCompose.
39 // *
40 // * It might be possible to convert these to ActivityUnitTest, which would be faster.
41 // */
42 //@LargeTest
43 //public class MessageViewTests
44 //        extends ActivityInstrumentationTestCase2<MessageView> {
45 //
46 //    // copied from MessageView (could be package class)
47 //    private static final String EXTRA_MESSAGE_ID = "com.android.email.MessageView_message_id";
48 //    private static final String EXTRA_MAILBOX_ID = "com.android.email.MessageView_mailbox_id";
49 //
50 //    private TextView mToView;
51 //    private TextView mSubjectView;
52 //    private WebView mMessageContentView;
53 //    private Context mContext;
54 //
55 //    public MessageViewTests() {
56 //        super(MessageView.class);
57 //    }
58 //
59 //    @Override
60 //    protected void setUp() throws Exception {
61 //        super.setUp();
62 //
63 //        mContext = getInstrumentation().getTargetContext();
64 //        Email.setTempDirectory(mContext);
65 //        Email.setServicesEnabled(mContext);
66 //
67 //        // setup an intent to spin up this activity with something useful
68 //        // Long.MIN_VALUE are sentinels to command MessageView to skip loading
69 //        Intent i = new Intent()
70 //            .putExtra(EXTRA_MESSAGE_ID, Long.MIN_VALUE)
71 //            .putExtra(EXTRA_MAILBOX_ID, Long.MIN_VALUE);
72 //        this.setActivityIntent(i);
73 //
74 //        // configure a mock controller
75 //        MessagingController mockController =
76 //            new MockMessagingController(getActivity().getApplication());
77 //        MessagingController.injectMockController(mockController);
78 //
79 //        final MessageView a = getActivity();
80 //        mToView = (TextView) a.findViewById(R.id.to);
81 //        mSubjectView = (TextView) a.findViewById(R.id.subject);
82 //        mMessageContentView = (WebView) a.findViewById(R.id.message_content);
83 //    }
84 //
85 //    /**
86 //     * The name 'test preconditions' is a convention to signal that if this
87 //     * test doesn't pass, the test case was not set up properly and it might
88 //     * explain any and all failures in other tests.  This is not guaranteed
89 //     * to run before other tests, as junit uses reflection to find the tests.
90 //     */
91 //    public void testPreconditions() {
92 //        assertNotNull(mToView);
93 //        assertEquals(0, mToView.length());
94 //        assertNotNull(mSubjectView);
95 //        assertEquals(0, mSubjectView.length());
96 //        assertNotNull(mMessageContentView);
97 //    }
98 //
99 //    /**
100 //     * Tests that various UI calls can be made safely even before the messaging controller
101 //     * has completed loading the message.  This catches various race conditions.
102 //     */
103 //    @Suppress
104 //    public void testUiRaceConditions() {
105 //
106 //        MessageView a = getActivity();
107 //
108 //        // on-streen controls
109 //        a.onClick(a.findViewById(R.id.reply));
110 //        a.onClick(a.findViewById(R.id.reply_all));
111 //        a.onClick(a.findViewById(R.id.delete));
112 //        a.onClick(a.findViewById(R.id.moveToOlder));
113 //        a.onClick(a.findViewById(R.id.moveToNewer));
114 ////      a.onClick(a.findViewById(R.id.download));    // not revealed yet, so unfair test
115 ////      a.onClick(a.findViewById(R.id.view));        // not revealed yet, so unfair test
116 //        a.onClick(a.findViewById(R.id.show_pictures));
117 //
118 //        // menus
119 //        a.handleMenuItem(R.id.delete);
120 //        a.handleMenuItem(R.id.reply);
121 //        a.handleMenuItem(R.id.reply_all);
122 //        a.handleMenuItem(R.id.forward);
123 //        a.handleMenuItem(R.id.mark_as_unread);
124 //    }
125 //
126 //    /**
127 //     * Sets EXTRA_DISABLE_REPLY on the intent to true/false, and
128 //     * checks change in replyButton.isEnabled().
129 //     */
130 //    @UiThreadTest
131 //    public void testDisableReply() {
132 //        MessageView a = getActivity();
133 //        View replyButton = a.findViewById(R.id.reply);
134 //
135 //        Intent i = new Intent();
136 //        a.setIntent(i);
137 //        a.initFromIntent();
138 //        assertTrue(replyButton.isEnabled());
139 //
140 //        i.putExtra(MessageView.EXTRA_DISABLE_REPLY, true);
141 //        a.setIntent(i);
142 //        a.initFromIntent();
143 //        assertFalse(replyButton.isEnabled());
144 //    }
145 //
146 //    /**
147 //     * Mock Messaging controller, so we can drive its callbacks.  This probably should be
148 //     * generalized since we're likely to use for other tests eventually.
149 //     */
150 //    private static class MockMessagingController extends MessagingController {
151 //
152 //        private MockMessagingController(Application application) {
153 //            super(application);
154 //        }
155 //    }
156 //}
157