1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 /**
23  *
24  */
25 package fvt.gui.formula.catalog;
26 
27 import static org.junit.Assert.*;
28 import static testlib.gui.UIMap.*;
29 
30 import org.junit.After;
31 import org.junit.Before;
32 import org.junit.Rule;
33 import org.junit.Test;
34 import org.openoffice.test.common.Logger;
35 
36 import testlib.gui.AppTool;
37 
38 public class CharacterFromCatalogDlg {
39 
40 	@Rule
41 	public Logger log = Logger.getLogger(this);
42 
43 	@Before
setUp()44 	public void setUp() throws Exception {
45 		app.start(true);
46 		AppTool.newFormula();
47 		// Click catalog button
48 		mathCatalogButton.click();
49 	}
50 
51 	@After
tearDown()52 	public void tearDown() throws Exception {
53 		AppTool.close();
54 		app.stop();
55 	}
56 
57 	/**
58 	 * Test input Greek character from Catalog->Symbols
59 	 *
60 	 * @throws Exception
61 	 */
62 	@Test
testInputGreekFromCatalog()63 	public void testInputGreekFromCatalog() throws Exception {
64 
65 		// Select "Greek", click "Edit" button to get the selected Symbol
66 		mathSymbolsDlgListbox.select(0);
67 		mathSymbolsDlgEditButton.click();
68 		String selectedSymbol = mathEditSymbolsDlgSymbol.getText();
69 		mathEditSymbolsDlg.ok();
70 
71 		// Insert the selected symbol
72 		mathSymbolsDlgInsertButton.click();
73 		mathSymbolsDlgCloseButton.click();
74 
75 		// Verify if the symbol is inserted successfully
76 		mathEditWindow.click(5, 5);
77 		app.dispatch(".uno:Select");
78 		app.dispatch(".uno:Copy");
79 		assertEquals("Symbol is not inserted succcessfully",
80 				"%".concat(selectedSymbol).concat(" "), app.getClipboard());
81 		// add "%" in the font, add " " in the end
82 
83 	}
84 
85 	/**
86 	 * Test input iGreek character from Catalog->Symbols
87 	 *
88 	 * @throws Exception
89 	 */
90 	@Test
testInputIGreekFromCatalog()91 	public void testInputIGreekFromCatalog() throws Exception {
92 
93 		// Select "iGreek", click "Edit" button to get the selected Symbol
94 		mathSymbolsDlgListbox.select(1);
95 		mathSymbolsDlgEditButton.click();
96 		String selectedSymbol = mathEditSymbolsDlgSymbol.getText();
97 		mathEditSymbolsDlg.ok();
98 
99 		// Insert the selected symbol
100 		mathSymbolsDlgInsertButton.click();
101 		mathSymbolsDlgCloseButton.click();
102 
103 		// Verify if the symbol is inserted successfully
104 		mathEditWindow.click(5, 5);
105 		app.dispatch(".uno:Select");
106 		app.dispatch(".uno:Copy");
107 		assertEquals("Symbol is not inserted succcessfully",
108 				"%".concat(selectedSymbol).concat(" "), app.getClipboard());
109 		// add "%" in the font, add " " in the end
110 	}
111 
112 	/**
113 	 * Test input Special character from Catalog->Symbols
114 	 *
115 	 * @throws Exception
116 	 */
117 	@Test
testInputSpecialFromCatalog()118 	public void testInputSpecialFromCatalog() throws Exception {
119 
120 		// Select "Special", "Insert" the default first symbol
121 		mathSymbolsDlgListbox.select(2);
122 		mathSymbolsDlgInsertButton.click();
123 
124 		// Click "Edit" button to get the selected Symbol
125 		mathSymbolsDlgEditButton.click();
126 		String selectedSymbol = mathEditSymbolsDlgSymbol.getText();
127 		mathEditSymbolsDlg.ok();
128 		mathSymbolsDlgCloseButton.click();
129 
130 		// Verify if the symbol is inserted successfully
131 		mathEditWindow.click(5, 5);
132 		app.dispatch(".uno:Select");
133 		app.dispatch(".uno:Copy");
134 		assertEquals("Symbol is not inserted succcessfully",
135 				"%".concat(selectedSymbol).concat(" "), app.getClipboard());
136 		// add "%" in the font, add " " in the end
137 	}
138 }
139