File indexing completed on 2024-05-19 05:41:55

0001 #!/bin/bash
0002 # Use: ./dbustest.sh /path/to/build /path/to/db
0003 
0004 if [ "$#" -ne 2 ]; then
0005     echo "Usage: $0 /path/to/build /path/to/db" 1>&2
0006     exit 1
0007 fi
0008 
0009 EXEC="$1/desktopapp/codevis"
0010 DB="$2"
0011 
0012 if ! [ -x "$EXEC" ]; then
0013     echo "$EXEC is not a build directory" 1>&2
0014     exit 1
0015 fi
0016 
0017 if ! [ -f "$DB" ]; then
0018     echo "$DB not found" 1>&2
0019     exit 1
0020 fi
0021 
0022 echo "Backing up configuration"
0023 mv ~/.config/Codethink/DiagramViewer.conf ~/.config/Codethink/DiagramViewer.conf-bkp > /dev/null 2>&1
0024 mv ~/.config/DiagramViewerrc ~/.config/DiagramViewerrc-bkp > /dev/null 2>&1
0025 
0026 # We store the logs here.
0027 # lakosdiagrma.log is the application log
0028 # timed_codevis is the dbus log, with all the time information for each call.
0029 
0030 rm codevis.log > /dev/null 2>&1
0031 rm timed_codevis.log > /dev/null 2>&1
0032 
0033 function cleanup {
0034   echo "Restoring configuration"
0035   mv ~/.config/Codethink/DiagramViewer.conf-bkp ~/.config/Codethink/DiagramViewer.conf > /dev/null 2>&1
0036   mv ~/.config/DiagramViewerrc-bkp ~/.config/DiagramViewerrc > /dev/null 2>&1
0037 }
0038 
0039 trap cleanup EXIT
0040 
0041 export DEFAULT_SLEEP=0.5s
0042 export TEE_CMD="tee -a timed_codevis.log"
0043 
0044 # Launch the app in background.
0045 "$EXEC" > codevis.log 2>&1 &
0046 
0047 # show the application pid
0048 echo "$!"
0049 
0050 # We have a lot of required word splitting, so let's silence shellcheck
0051 
0052 # Wait a bit for the application to launch
0053 sleep 2s
0054 
0055 # For all the possible methods, see codevisdbusinterface.h
0056 
0057 export DBUSCALL="dbus-send --print-reply --dest=org.codethink.CodeVis /Application org.codethink.CodeVis"
0058 
0059 # Loads a database file.
0060 echo "Loading Database" | $TEE_CMD
0061 # shellcheck disable=2086
0062 $DBUSCALL.requestLoadDatabase string:"$DB" >> timed_codevis.log 2>&1
0063 
0064 # Creates a new tab
0065 echo "Creating new tab" | $TEE_CMD
0066 # shellcheck disable=2086
0067 $DBUSCALL.requestNewTab >> timed_codevis.log 2>&1
0068 sleep "$DEFAULT_SLEEP"
0069 
0070 # Closes the tab.
0071 echo "Closing created tab" | $TEE_CMD
0072 # shellcheck disable=2086
0073 $DBUSCALL.requestCloseCurrentTab >> timed_codevis.log 2>&1
0074 sleep "$DEFAULT_SLEEP"
0075 
0076 # Opens the split view.
0077 echo "Open Split View" | $TEE_CMD
0078 # shellcheck disable=2086
0079 $DBUSCALL.requestToggleSplitView >> timed_codevis.log 2>&1
0080 sleep "$DEFAULT_SLEEP"
0081 
0082 echo "Selecting first split" | $TEE_CMD
0083 # shellcheck disable=2086
0084 $DBUSCALL.requestSelectLeftSplitView >> timed_codevis.log 2>&1
0085 
0086 # Creates a new tab
0087 echo "Open new tab on the first split" | $TEE_CMD
0088 # shellcheck disable=2086
0089 $DBUSCALL.requestNewTab >> timed_codevis.log 2>&1
0090 sleep "$DEFAULT_SLEEP"
0091 
0092 # Closes the tab.
0093 echo "Closing the tab"  | $TEE_CMD
0094 # shellcheck disable=2086
0095 $DBUSCALL.requestCloseCurrentTab >> timed_codevis.log 2>&1
0096 sleep "$DEFAULT_SLEEP"
0097 
0098 # shellcheck disable=2086
0099 $DBUSCALL.requestSelectRightSplitView >> timed_codevis.log 2>&1
0100 
0101 # Creates a new tab
0102 echo "Open tab on the second split"  | $TEE_CMD
0103 # shellcheck disable=2086
0104 $DBUSCALL.requestNewTab >> timed_codevis.log 2>&1
0105 sleep "$DEFAULT_SLEEP"
0106 
0107 # Closes the tab.
0108 echo "Close the tab on the second split"  | $TEE_CMD
0109 # shellcheck disable=2086
0110 $DBUSCALL.requestCloseCurrentTab >> timed_codevis.log 2>&1
0111 sleep "$DEFAULT_SLEEP"
0112 
0113 # Closes the split view.
0114 echo "Closing split view" | $TEE_CMD
0115 # shellcheck disable=2086
0116 $DBUSCALL.requestToggleSplitView >> timed_codevis.log 2>&1
0117 sleep "$DEFAULT_SLEEP"
0118 
0119 # Loads things from a single package, from the topmost, down to a class.
0120 # Try to load a Package Group, BAL.
0121 # loadEntity loads a specific, fully qualified name, entity.
0122 echo "Loading package group BAL"  | $TEE_CMD
0123 # shellcheck disable=2086
0124 $DBUSCALL.requestLoadPackage string:"bal" >> timed_codevis.log 2>&1
0125 sleep 2
0126 
0127 # Try to load a Package, balb.
0128 echo "Loading package BALB"  | $TEE_CMD
0129 # shellcheck disable=2086
0130 $DBUSCALL.requestLoadPackage string:"balb" >> timed_codevis.log 2>&1
0131 sleep 2
0132 
0133 # Try to load a Package, component.
0134 echo "Loading component balb_controlmanager"  | $TEE_CMD
0135 # shellcheck disable=2086
0136 $DBUSCALL.requestLoadComponent string:"balb_controlmanager" >> timed_codevis.log 2>&1
0137 sleep 2
0138 
0139 # Try to load a class..
0140 echo "Loading class BloombergLP::balb::ControlManager::ControlHandler"  | $TEE_CMD
0141 # shellcheck disable=2086
0142 $DBUSCALL.requestLoadClass string:"BloombergLP::balb::ControlManager::ControlHandler" >> timed_codevis.log 2>&1
0143 sleep 2
0144 
0145 # Load another package group.
0146 echo "Loading package group bbl" | $TEE_CMD
0147 # shellcheck disable=2086
0148 $DBUSCALL.requestLoadPackage string:"bbl" >> timed_codevis.log 2>&1
0149 sleep 2
0150 
0151 # Quits
0152 echo "Finalizing" | $TEE_CMD
0153 # shellcheck disable=2086
0154 $DBUSCALL.requestQuit  >> timed_codevis.log 2>&1