blob: 897e1e5bb7a88281fdb8745c35d5cd0ba04da962 [file] [log] [blame]
--- RCPTT testcase ---
Format-Version: 1.0
Context-Type: org.eclipse.rcptt.ctx.ecl
Element-Name: HelperScripts
Element-Type: context
Element-Version: 2.0
Id: _jPStUFRJEeaXLqlXvYQIgg
Runtime-Version: 2.1.0.201605312320
Save-Time: 5/18/17 10:42 AM
------=_.ecl.context-718f04b4-ed39-33e3-af62-0995e4561998
Content-Type: text/ecl
Entry-Name: .ecl.context
proc "delete-git-repos" {
try {
with [open-view "Git Repositories" "Git/Git Repositories" | get-tree] {
key-type "M1+a"
collapse-all
}
} -catch {
// In case the dialog does not have a tree
}
try {
let [val repoCount [get-view "Git Repositories" | get-tree | get-property "getItemCount()" -raw]] {
loop [val count $repoCount] {
if [$count | gt 0] {
with [get-view "Git Repositories" | get-tree | select ".*"] {
wait -ms $defaultWaitTime
get-quick-access | set-text "delete repo"
get-quick-access | key-type Enter
with [get-window "Delete Repository"] {
with [get-button "Delete Git repository data and history:"] {
key-type Enter
check
}
get-button "Also delete working tree:" | check
get-button OK | click
}
}
wait -ms $defaultWaitTime
recur [$count | minus 1]
}
}
}
} -catch {
// Nothing to do
}
}
// Initialte a local rebase by clicking rebase in the review editor and answer to prompts
proc "initiate-remote-rebase" [val editor -input] {
with [$editor] {
with [get-button "Rebase..."] {
click
get-menu "Rebase (remotely)" | click
}
}
with [get-window "Code Review - Rebase Change"] {
get-button OK | click
wait -ms $defaultWaitTime
}
with [get-window "Automatic local rebase"] {
get-button OK | click
wait -ms $defaultWaitTime
}
}
// Return the dashboard view. Open it if necessary.
proc getDashboard [] {
try {
get-view "Gerrit Dashboard (EGerrit)"
} -catch {
get-menu "Window/Show View/Other..." | click
with [get-window "Show View"] {
get-tree | select "Git/Gerrit Dashboard (EGerrit)"
get-button OK | click
}
get-view "Gerrit Dashboard (EGerrit)"
}
}
// Close the dashboard view
proc closeDashboard [] {
try {
get-view "Gerrit Dashboard (EGerrit)" | close
}
}
// Enter a query in the dashboard search dialog and execute it. The query is executed against the default server.
proc runQuery [val query] [val serverName $serverName] {
selectActiveServer -serverName $serverName
get-view "Gerrit Dashboard (EGerrit)" | get-combo | set-text $query
get-button Search | click
wait -ms $defaultWaitTime
}
proc selectActiveServer [val serverName] {
getDashboard | get-button "Select current Gerrit repository" | click -arrow
get-menu $serverName | click
}
// Run the query and open the review editor on the first match
proc runQueryAndOpenEditor [val query] [val serverName $serverName] {
try {
runQuery [$query | get lastChangeId] -serverName $serverName
} -catch {
runQuery [$query] -serverName $serverName
}
with [getDashboard] {
with [get-table] {
get-cell -row 0 -column 1 | double-click
}
}
wait -ms $defaultWaitTime
}
proc openCompareEditor [val query] [val serverName $serverName] {
runQueryAndOpenEditor $query $serverName
wait -ms $defaultWaitTime
with [get-table -index 1 | get-column-header "File Path"] {
click
}
// Select the first file in the list
with [get-editor | get-table -index 1] {
get-cell -row 0 -column 2 | double-click
}
try {
wait -ms $defaultWaitTime
// Click ok on tip
get-window "EGerrit Tip" | get-button OK | click
} -catch {
}
}
proc switchLeftInput [val to] [val in -input] {
with [$in | get-button -after [get-label -index 0]] {
click
get-menu $to | click
}
wait -ms $defaultWaitTime
}
proc switchRightInput [val to] [val in -input] {
with [$in | get-button -after [get-label -index 2]] {
click
get-menu $to | click
}
wait -ms $defaultWaitTime
}
proc insertComment [val on] [val text] [val atLine] [val save false] [val column 0] [val in -input] {
if [$on | equals right] {
doInsertComment -idx 1 -text $text -atLine $atLine -col $column -in $in
} -else {
doInsertComment -idx 0 -text $text -atLine $atLine -col $column -in $in
}
if [$save] {
with [$in] {
key-type "M1+s"
wait -ms $defaultWaitTime
}
}
}
proc doInsertComment [val idx] [val text] [val atLine] [val col 0] [val in -input] {
with [$in | get-text-viewer -index $idx] {
set-caret-pos -line $atLine -column $col
type-text $text
}
}
proc "assert-that-status-in-dashboard" [val is] {
getDashboard | get-table | get-item "Not starred review" | get-property "columns[3]" | equals $is | verify-true
}
proc "assert-that-subject-in-dashboard" [val is] {
getDashboard | get-table | get-item "Not starred review" | get-property "columns[2]" | equals $is | verify-true
}
proc "assert-that-first-entry-in-history-table" [val atColumn] [val is] [val in -input] {
with [$in] {
get-tab-folder | get-tab-item History | click
}
with [get-table] {
get-cell -row 0 -column 1 | get-property [concat "columns[" $atColumn "]"] | contains $is | verify-true
}
}
proc "assert-that-status-in-editor-header" [val is] [val in -input] {
$in | get-editbox -after [get-label "ID:"] -index 1 | get-property text | equals $is | verify-true
}
proc "assert-that-radio-button" [val button] [val is] [val in -input] {
with [$in] {
if [$is | equals enabled] {
get-button $button | get-property selected | equals true | verify-true
}
if [$is | equals disabled] {
get-button $button | get-property selected | equals false | verify-true
}
if [$is | equals "not-present"] {
verify-error {
get-button $button
}
}
}
}
proc "assert-that-button" [val button] [val is] [val in -input] {
with [$in] {
if [$is | equals enabled] {
get-button $button | get-property enablement | equals true | verify-true
}
if [$is | equals disabled] {
get-button $button | get-property enablement | equals false | verify-true
}
if [$is | equals "not-present"] {
verify-error {
get-button $button
}
}
}
}
proc "assert-that-search-box-in-dashboard" [val is] {
getDashboard | get-combo | get-property selection | equals $is | verify-true
}
proc "assert-that-subject-in-editor" [val is] [val in -input] {
$in | get-editbox -after [get-label "Subject:"] | get-property text | equals $is | verify-true
}
proc "assert-that-patchset-counter-in-editor" [val is] [val in -input] {
$in | get-label "Patch Sets.*" | get-property caption | contains $is | verify-true
}
proc "assert-that-left-selected-patch" [val is] [val in -input] {
with [$in] {
get-label -index 1 | get-property caption | equals $is | verify-true
}
}
proc "assert-that-right-selected-patch" [val is] [val in -input] {
with [$in] {
get-label -index 3 | get-property caption | equals $is | verify-true
}
}
proc "assert-that-left-editor-content" [val is] [val in -input] {
with [$in] {
get-editbox -index 0 | get-property text | contains $is | verify-true
}
}
proc "assert-that-right-editor-content" [val is] [val in -input] {
with [$in] {
get-editbox -index 1 | get-property text | contains $is | verify-true
}
}
proc "assert-that-compare-editor-titles-are" [val left] [val right] [val in -input] {
with [$in] {
get-label $left
get-label $right -after [get-label $left]
}
}
proc "assert-that-no-editor-present" [] {
try {
get-editor -index 0
verify-true 0
} -catch {
verify-true 1
}
}
proc "assert-that-patchset-menu" [val contains] [val in -input] {
with [$in | get-button -after [get-label "Patch Sets.*"]] {
click
get-menu $contains
}
}
proc "assert-that-number-of-files-in-compare" [val is] [val compare -input] {
with [$compare] {
get-tree | get-property "getItems().length" | equals $is | verify-true
}
}
proc "assert-that-selected-text" [val is] [val in -input] {
$in | get-property -name "getSelectionText()" | equals $is | verify-true
}
proc "get-left-editor" [val in -input] {
get-text-viewer -index 0
}
proc "get-right-editor" [val in -input] {
get-text-viewer -index 1
}
proc "assert-that-star-in-dashboard-is-off" [val is] {
assert-that-star-in-dashboard -is "org.eclipse.egerrit.dashboard.ui/icons/view16/starOpen.gif"
}
proc "assert-that-star-in-dashboard-is-on" [val is] [val in -input] {
assert-that-star-in-dashboard -is "org.eclipse.egerrit.dashboard.ui/icons/view16/starFilled.gif"
}
proc "assert-that-star-in-dashboard" [val is] [val in -input] {
getDashboard | get-table | get-cell -row 0 -column 0 | get-property "cells[0].image.path" | equals $is | verify-true
}
proc "assert-dialog" [val named] [val containsText] [val dismiss true] {
get-window $named | get-label $containsText | get-property caption | equals $containsText | verify-true
if [$dismiss | equals true] {
get-window $named | get-button OK | click
}
}
proc "assert-marker-count-is" [val is] {
get-view Markers | get-label [concat $is " items"] | get-property caption | equals [concat $is " items"]
| verify-true
}
proc "assert-sameTopic-table" [val contains] [val in -input] {
$in | get-group "Same Topic" | get-table | get-cell -row 1 -column 0 | get-property "columns[0]" | equals $contains
| verify-true
}
proc "assert-noEntry-in-topic-table" [val in -input] {
$in | get-group "Same Topic" | get-table | get-property itemCount | equals 0 | verify-true
}
proc "switch-user" [val to] {
// Add a server connected by an anonymous user and make it the default server
add-gerrit-server -serverURL $serverURL -serverName $to -userName $to
selectActiveServer -serverName $to
}
proc "assert-that-itemCount-in-history-is" [val is] {
get-property itemCount | equals $is | verify-true
}
proc "assert-that-status-in-compare" [val atLine] [val is] [val in -input] {
with [$in | get-tree] {
get-item "" -index $atLine | get-property "columns[1]" | equals $is | verify-true
}
}
proc "assert-that-leftCommentCount-in-compare" [val atLine] [val is] [val in -input] {
with [$in | get-tree] {
get-item "" -index $atLine | get-property "columns[3]" | equals $is | verify-true
}
}
proc "assert-that-rightCommentCount-in-compare" [val atLine] [val is] [val in -input] {
with [$in | get-tree] {
get-item "" -index $atLine | get-property "columns[4]" | equals $is | verify-true
}
}
proc "assert-that-filename-in-compare" [val atLine] [val is] [val in -input] {
with [$in | get-tree] {
get-item "" -index $atLine | get-property "columns[2]" | equals $is | verify-true
}
}
proc "assert-that-filename-in-dialog" [val atLine] [val is] [val in -input] {
with [$in | get-table] {
get-item "" -index $atLine | get-property "columns[2]" | equals $is | verify-true
}
}
proc "activate-review" [val in -input] {
$in | get-button "Activate Comment Markers" | check
try {
get-window "EGerrit Tip" | get-button OK | click
} -times 4 -delay $defaultWaitTime
}
proc "assert-that-reviewed-flag-is-off" [val row] {
try {
with [get-editor | get-table -index 1] {
get-cell $row 0 -column 0 | get-property "cells[0]" | equals "" | verify-true
}
} -times 4 -delay $defaultWaitTime
}
proc "assert-that-reviewed-flag-is-on" [val row] [val in -input] {
assert-that-reviewed-flag-in-files -row $row -is "org.eclipse.egerrit.ui/icons/greenCheck.png"
}
proc "assert-that-reviewed-flag-in-files" [val row] [val is] [val in -input] {
try {
with [get-editor | get-table -index 1] {
get-cell $row 0 -column 0 | get-property "cells[0].image.path" | equals $is | verify-true
}
} -times 4 -delay $defaultWaitTime
}
// Open the Problems view.
proc openProblemsView [] {
open-view Problems "General/Problems"
}
// Open the Markers view.
proc openMarkersView [] {
open-view Markers "General/Markers"
}
// Look at the items in the Problems view
proc "assert-problem-count-is" [val is] {
get-view Problems | get-label [concat $is " items"] | get-property caption | equals [concat $is " items"]
| verify-true
}
proc "open-view" [val viewName] [val viewPath] {
try {
get-view $viewName
} -catch {
get-menu "Window/Show View/Other..." | click
with [get-window "Show View"] {
get-tree | select $viewPath
get-button OK | click
}
get-view $viewName
}
}
proc "close-view" [val viewName] {
try {
get-view $viewName | close
} -catch {
}
}
proc "open-file" [val fileName] {
get-eclipse-window | key-type "M1+M2+r"
with [get-window "Open Resource"] {
get-editbox | set-text $fileName
get-table | select $fileName | double-click
}
}
proc "assert-that-editor" [val in -input] [val contains] [val close true] {
open-file $in
get-editor $in | get-text-viewer | get-property text | equals $contains | verify-true
if [$close] {
get-editor $in | close
}
}
proc "checkout-revision" [val in -input] [val ps] [val acceptPrompts false] {
with [$in] {
with [get-group "" | get-button -after [get-label "Patch Sets.*"]] {
click
get-menu $ps | click
}
with [get-button Download] {
click
get-menu "Checkout..." | click
}
}
if [$acceptPrompts] {
try {
get-window "Fetch a change from Gerrit" | get-button Finish | click
} -catch {
}
try {
get-window "EGerrit Tip" | get-button OK | click
} -catch {
}
}
}
proc "assert-colum-count-in-dashboard-is" [val is] {
getDashboard | get-table | get-property columnCount | equals $is | verify-true
}
proc "assert-colum-count-in-reviewers-is" [val is] {
// Test to see the number of columns in the Reviewers table includes the dynamic columns
with [get-editor] {
get-tab-folder | get-tab-item Details | click
get-group Reviewers | get-table | get-property columnCount | equals $is | verify-true
}
}
proc "assert-column-label-in-reviewers" [val col] [val label] {
// Test the column value is CR "Code-Review", V "Verified", etc
with [get-editor | get-group Reviewers | get-table] {
get-property [format "columns[%d].caption" $col] | equals $label | verify-true
}
}
proc "branch-rename" [val in -input] [val newBranchName] [val gitRepoBranch] {
with [$in] {
with [get-button Download] {
click
get-menu "Checkout..." | click
}
}
//Check out branch as specified
try {
with [get-window "Fetch a change from Gerrit"] {
get-group "Action to perform after fetch" | get-editbox -after [get-label "Branch name:"] | set-text $newBranchName
get-button Finish | click
}
} -catch {
}
try {
get-window "EGerrit Tip" | get-button OK | click
} -catch {
}
//Validation
branch-rename-validation -gitRepoBranch $gitRepoBranch -branch $newBranchName
}
proc "branch-rename-validation" [val gitRepoBranch] [val branch] {
//Validation
get-view "Git Repositories" | get-tree | get-item $gitRepoBranch
| get-property caption | contains $branch | verify-true
}
proc "assert-branch-rename-is" [val in -input] [val button] [val gitBranch ] [val lastBranchName] {
with [$in] {
with [get-button Download ] {
click
get-menu "Checkout..." | click
}
}
try {
get-window "EGerrit rename" | get-button $button | click
} -times 4 -delay $defaultWaitTime
//Validation
branch-rename-validation -gitRepoBranch $gitBranch -branch $lastBranchName
}
proc "prepare-a-server" [val serverURL] [val serverName] {
get-view "Gerrit Dashboard (EGerrit)" | get-button "Select current Gerrit repository" | click -arrow
get-menu "Add\\/Modify Gerrit Repository..." | click
with [get-window Preferences] {
get-button "New..." | click
with [get-window "Gerrit Server Selection"] {
get-editbox -after [get-label "URL:"] | set-text $serverURL
get-editbox -after [get-label "Label:"] | set-text $serverName
get-button OK | click
}
}
}
proc "close_preference-and-dialog" [val popupLevel1] [val popupLevel2] [val buttonLevel2] {
with [get-window Preferences] {
with [get-window $popupLevel1 ] {
with [get-window $popupLevel2 ] { get-button $buttonLevel2 | click }
}
with [get-window $popupLevel1 ] {
get-button Cancel | click
}
get-button Cancel | click
}
}
------=_.ecl.context-718f04b4-ed39-33e3-af62-0995e4561998--