1 /*
   2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2019, Red Hat Inc. All rights reserved.
   4  *
   5  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   6  *
   7  * The contents of this file are subject to the terms of either the Universal Permissive License
   8  * v 1.0 as shown at http://oss.oracle.com/licenses/upl
   9  *
  10  * or the following license:
  11  *
  12  * Redistribution and use in source and binary forms, with or without modification, are permitted
  13  * provided that the following conditions are met:
  14  *
  15  * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
  16  * and the following disclaimer.
  17  *
  18  * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
  19  * conditions and the following disclaimer in the documentation and/or other materials provided with
  20  * the distribution.
  21  *
  22  * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
  23  * endorse or promote products derived from this software without specific prior written permission.
  24  *
  25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  26  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  27  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  28  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
  32  * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33  */
  34 
  35 package org.openjdk.jmc.flightrecorder.uitest.pages;
  36 
  37 import org.junit.Rule;
  38 import org.junit.Test;
  39 import org.openjdk.jmc.flightrecorder.jdk.JdkAggregators;
  40 import org.openjdk.jmc.flightrecorder.ui.messages.internal.Messages;
  41 import org.openjdk.jmc.test.jemmy.MCUITestRule;
  42 import org.openjdk.jmc.test.jemmy.misc.wrappers.JfrNavigator;
  43 import org.openjdk.jmc.test.jemmy.misc.wrappers.JfrUi;
  44 import org.openjdk.jmc.test.jemmy.misc.wrappers.MC;
  45 import org.openjdk.jmc.test.jemmy.misc.wrappers.MCMenu;
  46 
  47 public class FileIOPageTest extends IOPageTestBase {
  48 
  49         private static final String DURATIONS_TAB = Messages.PAGES_DURATIONS;
  50         private static final String FILE_READ_COL = Messages.FileIOPage_ROW_FILE_READ;
  51         private static final String READ_COUNT_COL = JdkAggregators.FILE_READ_COUNT.getName();
  52         private static final String FILE_WRITE_COL = Messages.FileIOPage_ROW_FILE_WRITE;
  53         private static final String WRITE_COUNT_COL = JdkAggregators.FILE_WRITE_COUNT.getName();
  54         private static final String RECORDING = "io_test.jfr";
  55 
  56         private static final long[][] TABLE_VALUES = {
  57                 {  14560, 9212, 11848, 4653 },
  58                 {  14567, 9212, 41055, 3533 },
  59                 { 251007,  223, 41055, 3533 },
  60                 { 251007,  223, 43519,    6 },
  61                 { 251007,  223, 43519,    6 },
  62                 { 251007,  223, 43519,    6 },
  63                 { 251007,  223, 43519,    6 },
  64         };
  65 
  66         @Rule
  67         public MCUITestRule testRule = new MCUITestRule(verboseRuleOutput) {
  68                 @Override
  69                 public void after() {
  70                         MCMenu.closeActiveEditor();
  71                 }
  72         };
  73 
  74         @Test
  75         public void testPercentileTable() {
  76                 JfrUi.openJfr(materialize("jfr", RECORDING, FileIOPageTest.class));
  77                 JfrNavigator.selectTab(JfrUi.Tabs.FILE_IO);
  78 
  79                 MC.selectMcTab(DURATIONS_TAB);
  80                 checkPercentileTable(FILE_READ_COL, READ_COUNT_COL, FILE_WRITE_COL, WRITE_COUNT_COL, TABLE_VALUES);
  81         }
  82 
  83 }