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

Side by Side Diff: editor/tools/plugins/com.google.dart.tools.ui_test/src-ui/editor/refactoring/ExtractLocalRefactoringTest.java

Issue 18548007: UI tests for 'Rename' and 'Extract Local Variable' refactorings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2013, the Dart project authors.
3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
11 * or implied. See the License for the specific language governing permissions a nd limitations under
12 * the License.
13 */
14 package editor.refactoring;
15
16 import com.google.dart.tools.ui.actions.JdtActionConstants;
17 import com.google.dart.ui.test.driver.ShellClosedOperation;
18 import com.google.dart.ui.test.driver.ShellOperation;
19 import com.google.dart.ui.test.driver.Operation;
20 import com.google.dart.ui.test.helpers.WizardDialogHelper;
21 import com.google.dart.ui.test.util.UiContext;
22
23 import editor.AbstractDartEditorTest;
24
25
26 import org.eclipse.jface.action.IAction;
27
28 import java.util.concurrent.TimeUnit;
29
30 /**
31 * Test for the "Extract Local" refactoring.
32 */
33 public final class ExtractLocalRefactoringTest extends AbstractDartEditorTest {
34 private static class WizardHelper extends WizardDialogHelper {
35 public WizardHelper(UiContext context) {
36 super(context);
37 }
38
39 public void setName(String name) {
40 context.getTextByLabel("Variable name:").setText(name);
41 }
42 }
43
44 public void test_singleExpression() throws Exception {
45 openTestEditor(
46 "// filler filler filler filler filler filler filler filler filler fille r",
47 "main() {",
48 " print(123);",
49 "}");
50 // run "Rename" action
51 selectAndStartRename("123");
52 // animate wizard dialog
53 String wizardName = "Extract Local Variable";
54 addOperation(new ShellOperation(wizardName) {
55 @Override
56 public void run(UiContext context) throws Exception {
57 WizardHelper helper = new WizardHelper(context);
58 // invalid name
59 helper.setName("-name");
60 helper.assertMessage("Variable name must not start with '-'.");
61 // set new name
62 helper.setName("res");
63 helper.assertNoMessage();
64 // done
65 context.clickButton("OK");
66 }
67 });
68 addOperation(new ShellClosedOperation(wizardName));
69 // validate result
70 runUiOperations(60, TimeUnit.SECONDS);
71 assertTestUnitContent(
72 "// filler filler filler filler filler filler filler filler filler fille r",
73 "main() {",
74 " var res = 123;",
75 " print(res);",
76 "}");
77 }
78
79 private void selectAndStartRename(String pattern) throws Exception {
80 selectRange(pattern);
81 // run "Extract Local" action
82 final IAction action = getEditorAction(JdtActionConstants.EXTRACT_LOCAL);
83 addOperation(new Operation() {
84 @Override
85 public boolean isReady(UiContext context) throws Exception {
86 return action.isEnabled();
87 }
88
89 @Override
90 public void run(UiContext context) throws Exception {
91 action.run();
92 }
93 });
94 }
95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698