1*739258c9SLi Feng Wang /************************************************************** 2*739258c9SLi Feng Wang * 3*739258c9SLi Feng Wang * Licensed to the Apache Software Foundation (ASF) under one 4*739258c9SLi Feng Wang * or more contributor license agreements. See the NOTICE file 5*739258c9SLi Feng Wang * distributed with this work for additional information 6*739258c9SLi Feng Wang * regarding copyright ownership. The ASF licenses this file 7*739258c9SLi Feng Wang * to you under the Apache License, Version 2.0 (the 8*739258c9SLi Feng Wang * "License"); you may not use this file except in compliance 9*739258c9SLi Feng Wang * with the License. You may obtain a copy of the License at 10*739258c9SLi Feng Wang * 11*739258c9SLi Feng Wang * http://www.apache.org/licenses/LICENSE-2.0 12*739258c9SLi Feng Wang * 13*739258c9SLi Feng Wang * Unless required by applicable law or agreed to in writing, 14*739258c9SLi Feng Wang * software distributed under the License is distributed on an 15*739258c9SLi Feng Wang * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*739258c9SLi Feng Wang * KIND, either express or implied. See the License for the 17*739258c9SLi Feng Wang * specific language governing permissions and limitations 18*739258c9SLi Feng Wang * under the License. 19*739258c9SLi Feng Wang * 20*739258c9SLi Feng Wang *************************************************************/ 21*739258c9SLi Feng Wang 22*739258c9SLi Feng Wang /** 23*739258c9SLi Feng Wang * 24*739258c9SLi Feng Wang */ 25*739258c9SLi Feng Wang package svt.gui.sw; 26*739258c9SLi Feng Wang 27*739258c9SLi Feng Wang import static org.openoffice.test.common.Testspace.getFile; 28*739258c9SLi Feng Wang import static org.openoffice.test.common.Testspace.getPath; 29*739258c9SLi Feng Wang import static org.openoffice.test.common.Testspace.prepareData; 30*739258c9SLi Feng Wang import static org.openoffice.test.vcl.Tester.*; 31*739258c9SLi Feng Wang import static testlib.gui.AppTool.*; 32*739258c9SLi Feng Wang import static testlib.gui.UIMap.*; 33*739258c9SLi Feng Wang 34*739258c9SLi Feng Wang import java.io.FileOutputStream; 35*739258c9SLi Feng Wang import java.io.PrintStream; 36*739258c9SLi Feng Wang import java.util.HashMap; 37*739258c9SLi Feng Wang 38*739258c9SLi Feng Wang import org.junit.After; 39*739258c9SLi Feng Wang import org.junit.AfterClass; 40*739258c9SLi Feng Wang import org.junit.Before; 41*739258c9SLi Feng Wang import org.junit.BeforeClass; 42*739258c9SLi Feng Wang import org.junit.Ignore; 43*739258c9SLi Feng Wang import org.junit.Rule; 44*739258c9SLi Feng Wang import org.junit.Test; 45*739258c9SLi Feng Wang import org.junit.rules.TestName; 46*739258c9SLi Feng Wang import org.openoffice.test.common.DataSheet; 47*739258c9SLi Feng Wang import org.openoffice.test.common.FileUtil; 48*739258c9SLi Feng Wang import org.openoffice.test.common.Logger; 49*739258c9SLi Feng Wang import org.openoffice.test.common.SystemUtil; 50*739258c9SLi Feng Wang import org.openoffice.test.common.Testspace; 51*739258c9SLi Feng Wang 52*739258c9SLi Feng Wang public class BasicFuncOnWriter { 53*739258c9SLi Feng Wang @Rule 54*739258c9SLi Feng Wang public Logger log = Logger.getLogger(this); 55*739258c9SLi Feng Wang 56*739258c9SLi Feng Wang @Rule 57*739258c9SLi Feng Wang public TestName testname = new TestName(); 58*739258c9SLi Feng Wang 59*739258c9SLi Feng Wang private static DataSheet xmlResult; 60*739258c9SLi Feng Wang 61*739258c9SLi Feng Wang private String pid = null; 62*739258c9SLi Feng Wang 63*739258c9SLi Feng Wang private static int iterator = 100; 64*739258c9SLi Feng Wang 65*739258c9SLi Feng Wang private int i = 0; 66*739258c9SLi Feng Wang 67*739258c9SLi Feng Wang /** 68*739258c9SLi Feng Wang * @throws java.lang.Exception 69*739258c9SLi Feng Wang */ 70*739258c9SLi Feng Wang @BeforeClass 71*739258c9SLi Feng Wang public static void beforeClass() throws Exception { 72*739258c9SLi Feng Wang 73*739258c9SLi Feng Wang xmlResult = new DataSheet(getFile("output/svt_gui_sw.xml")); 74*739258c9SLi Feng Wang xmlResult.addRow("BasicFuncOnWriter","Method", "Iterator", "Consumed Time(MS)", 75*739258c9SLi Feng Wang "Memory(KB)", "CPU(%)"); 76*739258c9SLi Feng Wang } 77*739258c9SLi Feng Wang 78*739258c9SLi Feng Wang @AfterClass 79*739258c9SLi Feng Wang public static void afterClass() throws Exception { 80*739258c9SLi Feng Wang app.stop(); 81*739258c9SLi Feng Wang } 82*739258c9SLi Feng Wang 83*739258c9SLi Feng Wang @Before 84*739258c9SLi Feng Wang public void before()throws Exception{ 85*739258c9SLi Feng Wang app.start(true); 86*739258c9SLi Feng Wang } 87*739258c9SLi Feng Wang 88*739258c9SLi Feng Wang @Test 89*739258c9SLi Feng Wang public void saveNewSWWithPic() throws Exception { 90*739258c9SLi Feng Wang String pic = prepareData("image/blue_256x256.jpg"); 91*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 92*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 93*739258c9SLi Feng Wang createNewSW(); 94*739258c9SLi Feng Wang writer.menuItem("Insert->Picture->From File...").select(); 95*739258c9SLi Feng Wang sleep(2); 96*739258c9SLi Feng Wang filePickerPath.setText(pic); 97*739258c9SLi Feng Wang sleep(1); 98*739258c9SLi Feng Wang filePickerOpen.click(); 99*739258c9SLi Feng Wang sleep(5); 100*739258c9SLi Feng Wang typeKeys("<esc>"); 101*739258c9SLi Feng Wang sleep(2); 102*739258c9SLi Feng Wang saveAndReopenNewSW(i); 103*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 104*739258c9SLi Feng Wang addRecord(i, start, end); 105*739258c9SLi Feng Wang } 106*739258c9SLi Feng Wang } 107*739258c9SLi Feng Wang 108*739258c9SLi Feng Wang 109*739258c9SLi Feng Wang @Test 110*739258c9SLi Feng Wang public void saveNewSWWithBullet() throws Exception { 111*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 112*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 113*739258c9SLi Feng Wang createNewSW(); 114*739258c9SLi Feng Wang writer.typeKeys("The first"); 115*739258c9SLi Feng Wang writer.typeKeys("<enter>"); 116*739258c9SLi Feng Wang sleep(3); 117*739258c9SLi Feng Wang writer.typeKeys("The second"); 118*739258c9SLi Feng Wang app.dispatch(".uno:SelectAll"); 119*739258c9SLi Feng Wang writer.menuItem("Format->Bullets and Numbering...").select(); 120*739258c9SLi Feng Wang sleep(3); 121*739258c9SLi Feng Wang bulletPage.ok(); 122*739258c9SLi Feng Wang writer.typeKeys("<ctrl z"); 123*739258c9SLi Feng Wang sleep(1); 124*739258c9SLi Feng Wang writer.typeKeys("<ctrl y>"); 125*739258c9SLi Feng Wang sleep(1); 126*739258c9SLi Feng Wang writer.typeKeys("<ctrl end>"); 127*739258c9SLi Feng Wang writer.typeKeys("<enter>"); 128*739258c9SLi Feng Wang sleep(2); 129*739258c9SLi Feng Wang 130*739258c9SLi Feng Wang writer.focus(); 131*739258c9SLi Feng Wang saveAndReopenNewSW(i); 132*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 133*739258c9SLi Feng Wang addRecord(i, start, end); 134*739258c9SLi Feng Wang } 135*739258c9SLi Feng Wang } 136*739258c9SLi Feng Wang 137*739258c9SLi Feng Wang @Test 138*739258c9SLi Feng Wang public void saveNewSWWithUnDoDelete()throws Exception{ 139*739258c9SLi Feng Wang if(!sdDrawingToolbar.exists()){ 140*739258c9SLi Feng Wang app.dispatch(".uno:AvailableToolbars?Toolbar:string=toolbar"); 141*739258c9SLi Feng Wang } 142*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 143*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 144*739258c9SLi Feng Wang createNewSW(); 145*739258c9SLi Feng Wang app.dispatch(".uno:Ellipse"); 146*739258c9SLi Feng Wang writer.focus(); 147*739258c9SLi Feng Wang writer.drag(200, 200, 300, 300); 148*739258c9SLi Feng Wang typeKeys("<Delete>"); 149*739258c9SLi Feng Wang typeKeys("<ctrl z>"); 150*739258c9SLi Feng Wang typeKeys("<ctrl y>"); 151*739258c9SLi Feng Wang 152*739258c9SLi Feng Wang saveAndReopenNewSW(i); 153*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 154*739258c9SLi Feng Wang addRecord(i, start, end); 155*739258c9SLi Feng Wang } 156*739258c9SLi Feng Wang } 157*739258c9SLi Feng Wang 158*739258c9SLi Feng Wang 159*739258c9SLi Feng Wang @Test 160*739258c9SLi Feng Wang public void saveNewSWWithSpellCheck() throws Exception { 161*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 162*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 163*739258c9SLi Feng Wang createNewSW(); 164*739258c9SLi Feng Wang writer.typeKeys("goood"); 165*739258c9SLi Feng Wang sleep(2); 166*739258c9SLi Feng Wang writer.menuItem("Tools->Spelling and Grammar...").select(); 167*739258c9SLi Feng Wang sleep(2); 168*739258c9SLi Feng Wang spellcheckDlgSuggestionList.select(0); 169*739258c9SLi Feng Wang spellcheckDlgIgnoreOnce.click(); 170*739258c9SLi Feng Wang activeMsgBox.ok(); 171*739258c9SLi Feng Wang sleep(2); 172*739258c9SLi Feng Wang saveAndReopenNewSW(i); 173*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 174*739258c9SLi Feng Wang addRecord(i, start, end); 175*739258c9SLi Feng Wang } 176*739258c9SLi Feng Wang } 177*739258c9SLi Feng Wang 178*739258c9SLi Feng Wang @Test 179*739258c9SLi Feng Wang public void saveNewSWWithHeaderFooter() throws Exception { 180*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 181*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 182*739258c9SLi Feng Wang createNewSW(); 183*739258c9SLi Feng Wang writer.menuItem("Insert->Header->Default").select(); 184*739258c9SLi Feng Wang sleep(2); 185*739258c9SLi Feng Wang writer.typeKeys("Header"); 186*739258c9SLi Feng Wang sleep(2); 187*739258c9SLi Feng Wang writer.menuItem("Insert->Footer->Default").select(); 188*739258c9SLi Feng Wang sleep(2); 189*739258c9SLi Feng Wang writer.typeKeys("Footer"); 190*739258c9SLi Feng Wang sleep(2); 191*739258c9SLi Feng Wang writer.typeKeys("<ctrl end>"); 192*739258c9SLi Feng Wang sleep(2); 193*739258c9SLi Feng Wang writer.typeKeys("<enter>"); 194*739258c9SLi Feng Wang sleep(2); 195*739258c9SLi Feng Wang saveAndReopenNewSW(i); 196*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 197*739258c9SLi Feng Wang addRecord(i, start, end); 198*739258c9SLi Feng Wang } 199*739258c9SLi Feng Wang } 200*739258c9SLi Feng Wang 201*739258c9SLi Feng Wang @Test 202*739258c9SLi Feng Wang public void saveNewSWWithFrameAnchor() throws Exception { 203*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 204*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 205*739258c9SLi Feng Wang createNewSW(); 206*739258c9SLi Feng Wang writer.menuItem("Insert->Frame...").select(); 207*739258c9SLi Feng Wang sleep(2); 208*739258c9SLi Feng Wang writerFrameDlg.ok(); 209*739258c9SLi Feng Wang writer.menuItem("Format->Anchor->To Page").select(); 210*739258c9SLi Feng Wang sleep(2); 211*739258c9SLi Feng Wang writer.menuItem("Format->Anchor->To Paragraph").select(); 212*739258c9SLi Feng Wang sleep(2); 213*739258c9SLi Feng Wang writer.menuItem("Format->Anchor->To Character").select(); 214*739258c9SLi Feng Wang sleep(2); 215*739258c9SLi Feng Wang writer.menuItem("Format->Anchor->As Character").select(); 216*739258c9SLi Feng Wang sleep(2); 217*739258c9SLi Feng Wang writer.typeKeys("<esc>"); 218*739258c9SLi Feng Wang sleep(2); 219*739258c9SLi Feng Wang writer.typeKeys("<enter>"); 220*739258c9SLi Feng Wang sleep(2); 221*739258c9SLi Feng Wang saveAndReopenNewSW(i); 222*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 223*739258c9SLi Feng Wang addRecord(i, start, end); 224*739258c9SLi Feng Wang } 225*739258c9SLi Feng Wang } 226*739258c9SLi Feng Wang 227*739258c9SLi Feng Wang @Test 228*739258c9SLi Feng Wang public void saveNewSWWithSDAsOLE()throws Exception{ 229*739258c9SLi Feng Wang String linkFile = prepareData("pvt/plain_200p.odp"); 230*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 231*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 232*739258c9SLi Feng Wang createNewSW(); 233*739258c9SLi Feng Wang app.dispatch(".uno:InsertObject"); 234*739258c9SLi Feng Wang sleep(2); 235*739258c9SLi Feng Wang insertObject.waitForExistence(60, 2); 236*739258c9SLi Feng Wang objectFromFile.check(); 237*739258c9SLi Feng Wang objectFilePath.setText(linkFile); 238*739258c9SLi Feng Wang objectFileLink.check(); 239*739258c9SLi Feng Wang insertObject.ok(); 240*739258c9SLi Feng Wang sleep(10); 241*739258c9SLi Feng Wang 242*739258c9SLi Feng Wang writer.focus(); 243*739258c9SLi Feng Wang writer.doubleClick(200, 300); 244*739258c9SLi Feng Wang sleep(15); 245*739258c9SLi Feng Wang writer.activate(); 246*739258c9SLi Feng Wang writer.click(10, 10); 247*739258c9SLi Feng Wang sleep(5); 248*739258c9SLi Feng Wang 249*739258c9SLi Feng Wang saveAndReopenNewSW(i); 250*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 251*739258c9SLi Feng Wang addRecord(i, start, end); 252*739258c9SLi Feng Wang } 253*739258c9SLi Feng Wang } 254*739258c9SLi Feng Wang 255*739258c9SLi Feng Wang @Test 256*739258c9SLi Feng Wang public void saveNewSWWithTOC() throws Exception { 257*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 258*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 259*739258c9SLi Feng Wang createNewSW(); 260*739258c9SLi Feng Wang for (int j = 0; j < 6; j++) { 261*739258c9SLi Feng Wang writer.typeKeys(String.valueOf(j + 1)); 262*739258c9SLi Feng Wang writer.typeKeys("<enter>"); 263*739258c9SLi Feng Wang } 264*739258c9SLi Feng Wang writer.typeKeys("<ctrl home>"); 265*739258c9SLi Feng Wang for (int k = 0; k < 2; k++) { 266*739258c9SLi Feng Wang writer.typeKeys("<shift down>"); 267*739258c9SLi Feng Wang } 268*739258c9SLi Feng Wang if (!styleAndFormattingDlg.exists()) { 269*739258c9SLi Feng Wang app.dispatch(".uno:DesignerDialog"); 270*739258c9SLi Feng Wang sleep(2); 271*739258c9SLi Feng Wang } 272*739258c9SLi Feng Wang 273*739258c9SLi Feng Wang styleAndFormattingList.doubleClick(0.5, 0.25); 274*739258c9SLi Feng Wang sleep(2); 275*739258c9SLi Feng Wang writer.typeKeys("<down>"); 276*739258c9SLi Feng Wang writer.typeKeys("<right>"); 277*739258c9SLi Feng Wang writer.typeKeys("<left>"); 278*739258c9SLi Feng Wang for (int k = 0; k < 2; k++) { 279*739258c9SLi Feng Wang writer.typeKeys("<shift down>"); 280*739258c9SLi Feng Wang } 281*739258c9SLi Feng Wang styleAndFormattingList.doubleClick(0.5, 0.3); 282*739258c9SLi Feng Wang sleep(2); 283*739258c9SLi Feng Wang writer.typeKeys("<ctrl home>"); 284*739258c9SLi Feng Wang sleep(2); 285*739258c9SLi Feng Wang writer.menuItem("Insert->Indexes and Tables->Indexes and Tables...").select(); 286*739258c9SLi Feng Wang sleep(2); 287*739258c9SLi Feng Wang insertIndexDlg.ok(); 288*739258c9SLi Feng Wang sleep(2); 289*739258c9SLi Feng Wang writer.typeKeys("<ctrl end>"); 290*739258c9SLi Feng Wang saveAndReopenNewSW(i); 291*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 292*739258c9SLi Feng Wang addRecord(i, start, end); 293*739258c9SLi Feng Wang } 294*739258c9SLi Feng Wang } 295*739258c9SLi Feng Wang 296*739258c9SLi Feng Wang @Test 297*739258c9SLi Feng Wang public void splitMergeTableOnOpenedSW() throws Exception { 298*739258c9SLi Feng Wang String file = prepareData("svt/swdesign.odt"); 299*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 300*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 301*739258c9SLi Feng Wang app.dispatch(".uno:Open"); 302*739258c9SLi Feng Wang submitOpenDlg(file); 303*739258c9SLi Feng Wang writer.waitForExistence(10, 2); 304*739258c9SLi Feng Wang writer.typeKeys("<down>"); 305*739258c9SLi Feng Wang writer.typeKeys("<down>"); 306*739258c9SLi Feng Wang sleep(2); 307*739258c9SLi Feng Wang 308*739258c9SLi Feng Wang writer.menuItem("Table->Split Cells").select(); 309*739258c9SLi Feng Wang sleep(2); 310*739258c9SLi Feng Wang writerSplitCellDlg.ok(); 311*739258c9SLi Feng Wang sleep(2); 312*739258c9SLi Feng Wang 313*739258c9SLi Feng Wang writer.typeKeys("<shift down>"); 314*739258c9SLi Feng Wang writer.typeKeys("<shift down>"); 315*739258c9SLi Feng Wang writer.typeKeys("<shift down>"); 316*739258c9SLi Feng Wang writer.typeKeys("<shift down>"); 317*739258c9SLi Feng Wang writer.typeKeys("<shift down>"); 318*739258c9SLi Feng Wang sleep(2); 319*739258c9SLi Feng Wang writer.menuItem("Table->Merge Cells").select(); 320*739258c9SLi Feng Wang sleep(2); 321*739258c9SLi Feng Wang 322*739258c9SLi Feng Wang writer.typeKeys("<enter>"); 323*739258c9SLi Feng Wang closeWithoutSaveSW(); 324*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 325*739258c9SLi Feng Wang addRecord(i, start, end); 326*739258c9SLi Feng Wang } 327*739258c9SLi Feng Wang } 328*739258c9SLi Feng Wang 329*739258c9SLi Feng Wang @Test 330*739258c9SLi Feng Wang public void addDelColumnsRowsInTableOnOpenedSW() throws Exception { 331*739258c9SLi Feng Wang String file = prepareData("svt/swdesign.odt"); 332*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 333*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 334*739258c9SLi Feng Wang app.dispatch(".uno:Open"); 335*739258c9SLi Feng Wang submitOpenDlg(file); 336*739258c9SLi Feng Wang writer.waitForExistence(10, 2); 337*739258c9SLi Feng Wang writer.typeKeys("<down>"); 338*739258c9SLi Feng Wang writer.typeKeys("<down>"); 339*739258c9SLi Feng Wang sleep(2); 340*739258c9SLi Feng Wang 341*739258c9SLi Feng Wang app.dispatch(".uno:InsertRowDialog"); 342*739258c9SLi Feng Wang writerInsertRowsDlg.ok(); 343*739258c9SLi Feng Wang sleep(2); 344*739258c9SLi Feng Wang 345*739258c9SLi Feng Wang writer.menuItem("Table->Delete->Rows").select(); 346*739258c9SLi Feng Wang sleep(2); 347*739258c9SLi Feng Wang 348*739258c9SLi Feng Wang app.dispatch(".uno:InsertColumnDialog"); 349*739258c9SLi Feng Wang writerInsertColumnsDlg.ok(); 350*739258c9SLi Feng Wang sleep(2); 351*739258c9SLi Feng Wang 352*739258c9SLi Feng Wang writer.menuItem("Table->Delete->Columns").select(); 353*739258c9SLi Feng Wang sleep(2); 354*739258c9SLi Feng Wang 355*739258c9SLi Feng Wang closeWithoutSaveSW(); 356*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 357*739258c9SLi Feng Wang addRecord(i, start, end); 358*739258c9SLi Feng Wang } 359*739258c9SLi Feng Wang } 360*739258c9SLi Feng Wang 361*739258c9SLi Feng Wang @Test 362*739258c9SLi Feng Wang public void setParaPropertoesOnOpenedSW() throws Exception { 363*739258c9SLi Feng Wang String file = prepareData("pvt/plain_200p.odt"); 364*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 365*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 366*739258c9SLi Feng Wang app.dispatch(".uno:Open"); 367*739258c9SLi Feng Wang submitOpenDlg(file); 368*739258c9SLi Feng Wang writer.waitForExistence(10, 2); 369*739258c9SLi Feng Wang writer.focus(); 370*739258c9SLi Feng Wang app.dispatch(".uno:ParagraphDialog"); 371*739258c9SLi Feng Wang alignPage.select(); 372*739258c9SLi Feng Wang alignPageRight.check(); 373*739258c9SLi Feng Wang sleep(2); 374*739258c9SLi Feng Wang alignPageVerticalAlign.select("Bottom"); 375*739258c9SLi Feng Wang sleep(2); 376*739258c9SLi Feng Wang alignPage.ok(); 377*739258c9SLi Feng Wang sleep(2); 378*739258c9SLi Feng Wang writer.typeKeys("<ctrl end>"); 379*739258c9SLi Feng Wang sleep(5); 380*739258c9SLi Feng Wang 381*739258c9SLi Feng Wang closeWithoutSaveSW(); 382*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 383*739258c9SLi Feng Wang addRecord(i, start, end); 384*739258c9SLi Feng Wang } 385*739258c9SLi Feng Wang } 386*739258c9SLi Feng Wang 387*739258c9SLi Feng Wang @Test 388*739258c9SLi Feng Wang public void InsertPicToOpenedSW() throws Exception { 389*739258c9SLi Feng Wang String file = prepareData("pvt/plain_200p.odt"); 390*739258c9SLi Feng Wang String pic = prepareData("image/blue_256x256.jpg"); 391*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 392*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 393*739258c9SLi Feng Wang app.dispatch(".uno:Open"); 394*739258c9SLi Feng Wang submitOpenDlg(file); 395*739258c9SLi Feng Wang writer.waitForExistence(10, 2); 396*739258c9SLi Feng Wang writer.focus(); 397*739258c9SLi Feng Wang writer.menuItem("Insert->Picture->From File...").select(); 398*739258c9SLi Feng Wang sleep(2); 399*739258c9SLi Feng Wang filePickerPath.setText(pic); 400*739258c9SLi Feng Wang sleep(1); 401*739258c9SLi Feng Wang filePickerOpen.click(); 402*739258c9SLi Feng Wang sleep(5); 403*739258c9SLi Feng Wang writer.typeKeys("<esc>"); 404*739258c9SLi Feng Wang sleep(2); 405*739258c9SLi Feng Wang closeWithoutSaveSW(); 406*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 407*739258c9SLi Feng Wang addRecord(i, start, end); 408*739258c9SLi Feng Wang } 409*739258c9SLi Feng Wang } 410*739258c9SLi Feng Wang 411*739258c9SLi Feng Wang @Test 412*739258c9SLi Feng Wang public void InsertOLEToOpenedSW() throws Exception { 413*739258c9SLi Feng Wang String file = prepareData("pvt/plain_200p.odt"); 414*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 415*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 416*739258c9SLi Feng Wang app.dispatch(".uno:Open"); 417*739258c9SLi Feng Wang submitOpenDlg(file); 418*739258c9SLi Feng Wang writer.waitForExistence(10, 2); 419*739258c9SLi Feng Wang writer.focus(); 420*739258c9SLi Feng Wang app.dispatch(".uno:InsertObject"); 421*739258c9SLi Feng Wang sleep(2); 422*739258c9SLi Feng Wang insertObject.ok(); 423*739258c9SLi Feng Wang sleep(10); 424*739258c9SLi Feng Wang typeKeys("<esc>"); 425*739258c9SLi Feng Wang sleep(5); 426*739258c9SLi Feng Wang typeKeys("<esc>"); 427*739258c9SLi Feng Wang sleep(5); 428*739258c9SLi Feng Wang closeWithoutSaveSW(); 429*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 430*739258c9SLi Feng Wang addRecord(i, start, end); 431*739258c9SLi Feng Wang } 432*739258c9SLi Feng Wang } 433*739258c9SLi Feng Wang 434*739258c9SLi Feng Wang @Test 435*739258c9SLi Feng Wang public void InsertChartToOpenedSW() throws Exception { 436*739258c9SLi Feng Wang String file = prepareData("pvt/plain_200p.odt"); 437*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 438*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 439*739258c9SLi Feng Wang app.dispatch(".uno:Open"); 440*739258c9SLi Feng Wang submitOpenDlg(file); 441*739258c9SLi Feng Wang writer.waitForExistence(10, 2); 442*739258c9SLi Feng Wang writer.focus(); 443*739258c9SLi Feng Wang writer.menuItem("Insert->Object->Chart...").select(); 444*739258c9SLi Feng Wang sleep(5); 445*739258c9SLi Feng Wang typeKeys("<esc>"); 446*739258c9SLi Feng Wang sleep(5); 447*739258c9SLi Feng Wang typeKeys("<esc>"); 448*739258c9SLi Feng Wang sleep(5); 449*739258c9SLi Feng Wang typeKeys("<esc>"); 450*739258c9SLi Feng Wang sleep(5); 451*739258c9SLi Feng Wang closeWithoutSaveSW(); 452*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 453*739258c9SLi Feng Wang addRecord(i, start, end); 454*739258c9SLi Feng Wang } 455*739258c9SLi Feng Wang } 456*739258c9SLi Feng Wang 457*739258c9SLi Feng Wang @Test 458*739258c9SLi Feng Wang public void openSWWithXForm()throws Exception{ 459*739258c9SLi Feng Wang String file = prepareData("svt/sickness_self-certification_meory issue.odt"); 460*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 461*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 462*739258c9SLi Feng Wang app.dispatch(".uno:Open"); 463*739258c9SLi Feng Wang submitOpenDlg(file); 464*739258c9SLi Feng Wang writer.waitForExistence(10, 2); 465*739258c9SLi Feng Wang app.dispatch(".uno:CloseDoc"); 466*739258c9SLi Feng Wang 467*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 468*739258c9SLi Feng Wang addRecord(i, start, end); 469*739258c9SLi Feng Wang } 470*739258c9SLi Feng Wang } 471*739258c9SLi Feng Wang 472*739258c9SLi Feng Wang @Test 473*739258c9SLi Feng Wang public void openSWWithSecuritySignature()throws Exception{ 474*739258c9SLi Feng Wang String file = prepareData("svt/howtouse.odt"); 475*739258c9SLi Feng Wang for (i = 1; i <= iterator; i++) { 476*739258c9SLi Feng Wang long start = System.currentTimeMillis(); 477*739258c9SLi Feng Wang app.dispatch(".uno:Open"); 478*739258c9SLi Feng Wang submitOpenDlg(file); 479*739258c9SLi Feng Wang writer.waitForExistence(10, 2); 480*739258c9SLi Feng Wang app.dispatch(".uno:CloseDoc"); 481*739258c9SLi Feng Wang 482*739258c9SLi Feng Wang long end = System.currentTimeMillis(); 483*739258c9SLi Feng Wang addRecord(i, start, end); 484*739258c9SLi Feng Wang } 485*739258c9SLi Feng Wang } 486*739258c9SLi Feng Wang 487*739258c9SLi Feng Wang 488*739258c9SLi Feng Wang private void createNewSW() { 489*739258c9SLi Feng Wang app.dispatch("private:factory/swriter"); 490*739258c9SLi Feng Wang } 491*739258c9SLi Feng Wang 492*739258c9SLi Feng Wang private void saveAndReopenNewSW(int iterator) { 493*739258c9SLi Feng Wang String saveTo = getPath("temp/" + "tempSW_New" + iterator + ".odt"); 494*739258c9SLi Feng Wang writer.menuItem("File->Save As...").select(); 495*739258c9SLi Feng Wang FileUtil.deleteFile(saveTo); 496*739258c9SLi Feng Wang submitSaveDlg(saveTo); 497*739258c9SLi Feng Wang if (activeMsgBox.exists()) { 498*739258c9SLi Feng Wang activeMsgBox.yes(); 499*739258c9SLi Feng Wang sleep(2); 500*739258c9SLi Feng Wang } 501*739258c9SLi Feng Wang app.dispatch(".uno:CloseDoc"); 502*739258c9SLi Feng Wang startCenterOpenButton.waitForExistence(30, 2); 503*739258c9SLi Feng Wang startCenterOpenButton.click(); 504*739258c9SLi Feng Wang submitOpenDlg(saveTo); 505*739258c9SLi Feng Wang sleep(1); 506*739258c9SLi Feng Wang app.dispatch(".uno:CloseDoc"); 507*739258c9SLi Feng Wang } 508*739258c9SLi Feng Wang 509*739258c9SLi Feng Wang private void closeWithoutSaveSW() { 510*739258c9SLi Feng Wang writer.menuItem("File->Close").select(); 511*739258c9SLi Feng Wang if (activeMsgBox.exists()) { 512*739258c9SLi Feng Wang activeMsgBox.no(); 513*739258c9SLi Feng Wang sleep(2); 514*739258c9SLi Feng Wang } 515*739258c9SLi Feng Wang } 516*739258c9SLi Feng Wang 517*739258c9SLi Feng Wang private HashMap<String, Object> getPerfData() { 518*739258c9SLi Feng Wang HashMap<String, Object> proccessInfo = SystemUtil 519*739258c9SLi Feng Wang .findProcess(".*(soffice\\.bin|soffice\\.exe|soffice).*"); 520*739258c9SLi Feng Wang String pid = (String) proccessInfo.get("pid"); 521*739258c9SLi Feng Wang return SystemUtil.getProcessPerfData(pid); 522*739258c9SLi Feng Wang } 523*739258c9SLi Feng Wang 524*739258c9SLi Feng Wang private void addRecord(int i, long start, long end) { 525*739258c9SLi Feng Wang HashMap<String, Object> perf = getPerfData(); 526*739258c9SLi Feng Wang xmlResult.addRow("BasicFuncOnWriter",testname.getMethodName(), i, (end - start), 527*739258c9SLi Feng Wang perf.get("rss"), perf.get("pcpu")); 528*739258c9SLi Feng Wang } 529*739258c9SLi Feng Wang 530*739258c9SLi Feng Wang } 531