From 4f6371397f0880f6ce4c011eb1c8461fe44f9c53 Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Tue, 26 Jan 2010 07:34:12 +0100 Subject: [PATCH] Create an automatic UI test for the Git Import Wizard Things like dialogs and such require a different approach. The strategy is to use SWTBot for runnings UI-oriented tests. Cleanup and restructuring by Ketan Padegaonkar using page objects * (http://code.google.com/p/webdriver/wiki/PageObjects) CQ: 3738 Bug: 300768 Change-Id: Ibc4c7a5ad6d9747fceb516c02d96dfc2b09d3b5a Signed-off-by: Robin Rosenberg Signed-off-by: Matthias Sohn --- org.eclipse.egit.ui.test/.classpath | 7 + org.eclipse.egit.ui.test/.gitignore | 2 + org.eclipse.egit.ui.test/.project | 28 ++ .../.settings/org.eclipse.jdt.core.prefs | 320 +++++++++++++++++++ org.eclipse.egit.ui.test/META-INF/MANIFEST.MF | 33 ++ org.eclipse.egit.ui.test/build.properties | 4 + .../org.eclipse.egit.ui--All tests.launch | 38 +++ .../src/org/eclipse/egit/ui/test/Activator.java | 57 ++++ .../src/org/eclipse/egit/ui/test/AllTests.java | 20 ++ .../src/org/eclipse/egit/ui/test/Eclipse.java | 71 +++++ .../egit/ui/wizards/clone/GitCloneWizardTest.java | 339 +++++++++++++++++++++ .../egit/ui/wizards/clone/GitImportRepoWizard.java | 32 ++ .../egit/ui/wizards/clone/RepoPropertiesPage.java | 73 +++++ .../ui/wizards/clone/RepoRemoteBranchesPage.java | 76 +++++ .../egit/ui/wizards/clone/WorkingCopyPage.java | 63 ++++ 15 files changed, 1163 insertions(+) create mode 100644 org.eclipse.egit.ui.test/.classpath create mode 100644 org.eclipse.egit.ui.test/.gitignore create mode 100644 org.eclipse.egit.ui.test/.project create mode 100644 org.eclipse.egit.ui.test/.settings/org.eclipse.jdt.core.prefs create mode 100644 org.eclipse.egit.ui.test/META-INF/MANIFEST.MF create mode 100644 org.eclipse.egit.ui.test/build.properties create mode 100644 org.eclipse.egit.ui.test/org.eclipse.egit.ui--All tests.launch create mode 100644 org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/Activator.java create mode 100644 org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/AllTests.java create mode 100644 org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/Eclipse.java create mode 100644 org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java create mode 100644 org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitImportRepoWizard.java create mode 100644 org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoPropertiesPage.java create mode 100644 org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoRemoteBranchesPage.java create mode 100644 org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/WorkingCopyPage.java diff --git a/org.eclipse.egit.ui.test/.classpath b/org.eclipse.egit.ui.test/.classpath new file mode 100644 index 00000000..64c5e31b --- /dev/null +++ b/org.eclipse.egit.ui.test/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.eclipse.egit.ui.test/.gitignore b/org.eclipse.egit.ui.test/.gitignore new file mode 100644 index 00000000..d567ba01 --- /dev/null +++ b/org.eclipse.egit.ui.test/.gitignore @@ -0,0 +1,2 @@ +bin +target diff --git a/org.eclipse.egit.ui.test/.project b/org.eclipse.egit.ui.test/.project new file mode 100644 index 00000000..48cf46e6 --- /dev/null +++ b/org.eclipse.egit.ui.test/.project @@ -0,0 +1,28 @@ + + + org.eclipse.egit.ui.test + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/org.eclipse.egit.ui.test/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.egit.ui.test/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..4d9814fd --- /dev/null +++ b/org.eclipse.egit.ui.test/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,320 @@ +#Thu Jan 08 19:39:17 CET 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private +org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=error +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=error +org.eclipse.jdt.core.compiler.problem.unusedLabel=error +org.eclipse.jdt.core.compiler.problem.unusedLocal=error +org.eclipse.jdt.core.compiler.problem.unusedParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error +org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=1 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false +org.eclipse.jdt.core.formatter.comment.format_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=80 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false diff --git a/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF b/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF new file mode 100644 index 00000000..b1ea8fa1 --- /dev/null +++ b/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF @@ -0,0 +1,33 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Test Plug-in +Bundle-SymbolicName: org.eclipse.egit.ui.test +Bundle-Version: 0.6.0.qualifier +Bundle-Activator: org.eclipse.egit.ui.test.Activator +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Import-Package: org.apache.log4j, + org.eclipse.core.resources, + org.eclipse.core.runtime;version="3.4.0", + org.eclipse.core.runtime.jobs, + org.eclipse.jgit.lib;version="0.6.0", + org.eclipse.swt.widgets, + org.eclipse.swtbot.eclipse.finder, + org.eclipse.swtbot.eclipse.finder.exceptions, + org.eclipse.swtbot.eclipse.finder.finders, + org.eclipse.swtbot.eclipse.finder.waits, + org.eclipse.swtbot.eclipse.finder.widgets, + org.eclipse.swtbot.swt.finder, + org.eclipse.swtbot.swt.finder.exceptions, + org.eclipse.swtbot.swt.finder.finders, + org.eclipse.swtbot.swt.finder.junit, + org.eclipse.swtbot.swt.finder.results, + org.eclipse.swtbot.swt.finder.utils, + org.eclipse.swtbot.swt.finder.waits, + org.eclipse.swtbot.swt.finder.widgets, + org.eclipse.ui, + org.hamcrest, + org.junit;version="4.3.1", + org.junit.runner;version="4.3.1", + org.junit.runners;version="4.3.1", + org.osgi.framework;version="1.4.0" diff --git a/org.eclipse.egit.ui.test/build.properties b/org.eclipse.egit.ui.test/build.properties new file mode 100644 index 00000000..b6cec20b --- /dev/null +++ b/org.eclipse.egit.ui.test/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/org.eclipse.egit.ui.test/org.eclipse.egit.ui--All tests.launch b/org.eclipse.egit.ui.test/org.eclipse.egit.ui--All tests.launch new file mode 100644 index 00000000..bee87996 --- /dev/null +++ b/org.eclipse.egit.ui.test/org.eclipse.egit.ui--All tests.launch @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/Activator.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/Activator.java new file mode 100644 index 00000000..ce8a61c4 --- /dev/null +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/Activator.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (C) 2009, Robin Rosenberg + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.egit.ui.test; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends Plugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.egit.ui.test"; + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + // Empty + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/AllTests.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/AllTests.java new file mode 100644 index 00000000..20739b90 --- /dev/null +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/AllTests.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (C) 2010, Ketan Padegaonkar + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.egit.ui.test; + +import org.eclipse.egit.ui.wizards.clone.GitCloneWizardTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ GitCloneWizardTest.class }) +public class AllTests { + // empty class, don't need anything here +} diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/Eclipse.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/Eclipse.java new file mode 100644 index 00000000..ef250b1c --- /dev/null +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/Eclipse.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (C) 2010, Ketan Padegaonkar + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.egit.ui.test; + +import java.util.List; + +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.eclipse.finder.finders.WorkbenchContentsFinder; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; +import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; +import org.eclipse.swtbot.swt.finder.results.BoolResult; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; + +public class Eclipse { + + private final SWTWorkbenchBot bot; + + public Eclipse() { + this.bot = new SWTWorkbenchBot(); + } + + /** + * Save and close all editors. Close all dialogs. + */ + public void reset() { + saveAll(); + closeAllEditors(); + closeAllShells(); + } + + private void closeAllShells() { + SWTBotShell[] shells = bot.shells(); + for (SWTBotShell shell : shells) { + if (!isEclipseShell(shell)) { + shell.close(); + } + } + } + + @SuppressWarnings("boxing") + public static boolean isEclipseShell(final SWTBotShell shell) { + return UIThreadRunnable.syncExec(new BoolResult() { + + public Boolean run() { + return new WorkbenchContentsFinder().activeWorkbenchWindow() + .getShell() == shell.widget; + } + }); + } + + public void closeAllEditors() { + List editors = bot.editors(); + for (SWTBotEditor editor : editors) { + editor.close(); + } + } + + public void saveAll() { + List editors = bot.editors(); + for (SWTBotEditor editor : editors) { + editor.save(); + } + } + +} diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java new file mode 100644 index 00000000..83d188a3 --- /dev/null +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java @@ -0,0 +1,339 @@ +/******************************************************************************* + * Copyright (C) 2009, Robin Rosenberg + * Copyright (C) 2010, Ketan Padegaonkar + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.egit.ui.wizards.clone; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.io.File; + +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Platform; +import org.eclipse.egit.ui.test.Eclipse; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(SWTBotJunit4ClassRunner.class) +public class GitCloneWizardTest { + static { + System.setProperty("org.eclipse.swtbot.playback.delay", "50"); + } + + private static final SWTWorkbenchBot bot = new SWTWorkbenchBot(); + + private GitImportRepoWizard importWizard; + + @Test + public void updatesParameterFieldsInImportDialogWhenURIIsUpdated() + throws Exception { + + RepoPropertiesPage propertiesPage = importWizard.openWizard(); + + propertiesPage.setURI("git://www.jgit.org/EGIT"); + propertiesPage.assertSourceParams(null, "www.jgit.org", "/EGIT", "git", + "", true, "", "", false, false); + + propertiesPage.appendToURI("X"); + + propertiesPage.assertSourceParams(null, "www.jgit.org", "/EGITX", + "git", "", true, "", "", false, false); + + propertiesPage.setURI("git://www.jgit.org/EGIT"); + propertiesPage.assertSourceParams(null, "www.jgit.org", "/EGIT", "git", + "", true, "", "", false, false); + + propertiesPage.setURI("git://user:hi@www.jgit.org/EGIT"); + propertiesPage.assertSourceParams( + " User not supported on git protocol.", "www.jgit.org", + "/EGIT", "git", "", true, "user", "hi", false, false); + + // UI doesn't change URI even when password is entered in clear text as + // part of URI. Opinions on this may vary. + propertiesPage.assertURI("git://user:hi@www.jgit.org/EGIT"); + + propertiesPage.setURI("ssh://user@www.jgit.org/EGIT"); + propertiesPage.assertSourceParams(null, "www.jgit.org", "/EGIT", + "git+ssh", "", true, "user", "", true, true); + + propertiesPage.setURI("ssh://user@www.jgit.org/EGIT"); + propertiesPage.assertSourceParams(null, "www.jgit.org", "/EGIT", + "git+ssh", "", true, "user", "", true, true); + + propertiesPage.setURI("ssh://user:hi@www.jgit.org:33/EGIT"); + propertiesPage.assertSourceParams(null, "www.jgit.org", "/EGIT", + "git+ssh", "33", true, "user", "hi", true, true); + + propertiesPage.setURI("ssh:///EGIT"); + propertiesPage.assertSourceParams(" Host required for ssh protocol.", + "", "/EGIT", "git+ssh", "", true, "", "", true, true); + + propertiesPage.setURI("file:///some/place"); + if (Platform.getOS().equals(Platform.OS_WIN32)) + propertiesPage.assertSourceParams(" " + + System.getProperty("user.dir") + + "\\.\\some\\place does not exist.", "", "/some/place", + "file", "", false, "", "", false, false); + else + propertiesPage.assertSourceParams(" /some/place does not exist.", + "", "/some/place", "file", "", false, "", "", false, false); + + // Now try changing some fields other than URI and see how the URI field + // gets changed + propertiesPage.setURI("ssh://user@www.jgit.org/EGIT"); + + // ..change host + bot.textWithLabel("Host:").setText("example.com"); + propertiesPage.assertURI("ssh://user@example.com/EGIT"); + + propertiesPage.assertSourceParams(null, "example.com", "/EGIT", + "git+ssh", "", true, "user", "", true, true); + + // ..change user + bot.textWithLabel("User:").setText("gitney"); + propertiesPage.assertURI("ssh://gitney@example.com/EGIT"); + propertiesPage.assertSourceParams(null, "example.com", "/EGIT", + "git+ssh", "", true, "gitney", "", true, true); + + // ..change password + bot.textWithLabel("Password:").setText("fsck"); + // Password is not written into the URL here! + propertiesPage.assertURI("ssh://gitney@example.com/EGIT"); + propertiesPage.assertSourceParams(null, "example.com", "/EGIT", + "git+ssh", "", true, "gitney", "fsck", true, true); + + // change port number + bot.textWithLabel("Port:").setText("99"); + propertiesPage.assertURI("ssh://gitney@example.com:99/EGIT"); + propertiesPage.assertSourceParams(null, "example.com", "/EGIT", + "git+ssh", "99", true, "gitney", "fsck", true, true); + + // change protocol to another with user/password capability + bot.comboBoxWithLabel("Protocol:").setSelection("ftp"); + propertiesPage.assertURI("ftp://gitney@example.com:99/EGIT"); + propertiesPage.assertSourceParams(null, "example.com", "/EGIT", "ftp", + "99", true, "gitney", "fsck", true, true); + + // change protocol to one without user/password capability + bot.comboBoxWithLabel("Protocol:").setSelection("git"); + propertiesPage.assertURI("git://gitney@example.com:99/EGIT"); + propertiesPage.assertSourceParams( + " User not supported on git protocol.", "example.com", "/EGIT", + "git", "99", true, "gitney", "fsck", false, false); + + // change protocol to one without host capability + bot.comboBoxWithLabel("Protocol:").setSelection("file"); + propertiesPage.assertURI("file://gitney@example.com:99/EGIT"); + propertiesPage.assertSourceParams( + " Host not supported on file protocol.", "example.com", + "/EGIT", "file", "99", false, "gitney", "fsck", false, false); + + // Local protocol with file: prefix. We need to make sure the + // local path exists as a directory so we choose user.home as + // that one should exist. + if (Platform.getOS().equals(Platform.OS_WIN32)) + propertiesPage.setURI("file:///" + System.getProperty("user.home")); + else + propertiesPage.setURI("file://" + System.getProperty("user.home")); + propertiesPage.assertSourceParams(null, "", System.getProperty( + "user.home").replace('\\', '/'), "file", "", false, "", "", + false, false); + + // Local protocol without file: prefix + propertiesPage.setURI(System.getProperty("user.home")); + propertiesPage.assertSourceParams(null, "", System.getProperty( + "user.home").replace('\\', '/'), "file", "", false, "", "", + false, false); + + // On windows the use can choose forward or backward slashes, so add + // a case for forward slashes using the non prefixed local protocol. + if (Platform.getOS().equals(Platform.OS_WIN32)) { + propertiesPage.setURI(System.getProperty("user.home").replace('\\', + '/')); + propertiesPage.assertSourceParams(null, "", System.getProperty( + "user.home").replace('\\', '/'), "file", "", false, "", "", + false, false); + } + bot.button("Cancel").click(); + } + + @SuppressWarnings("boxing") + @Test + public void canCloneARemoteRepo() throws Exception { + File destRepo = new File(new File(ResourcesPlugin.getWorkspace() + .getRoot().getLocation().toFile().getParent(), + "junit-workspace"), "egit"); + + RepoPropertiesPage propertiesPage = importWizard.openWizard(); + + RepoRemoteBranchesPage remoteBranches = propertiesPage + .nextToRemoteBranches("git://repo.or.cz/egit.git"); + + remoteBranches.assertRemoteBranches("historical/pre-eclipse", "master"); + remoteBranches.selectBranches("historical/pre-eclipse"); + + WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy(); + + workingCopy.assertDirectory(destRepo.toString()); + workingCopy.assertBranch("master"); + workingCopy.assertRemoteName("origin"); + workingCopy.doNotImportProjectsAfterClone(); + workingCopy.waitForCreate(); + + // Some random sampling to see we got something. We do not test + // the integrity of the repository here. Only a few basic properties + // we'd expect from a clone made this way, that would possibly + // not hold true given other parameters in the GUI. + Repository repository = new Repository(new File(destRepo, ".git")); + // we always have an origin/master + assertNotNull(repository.resolve("origin/master")); + // and a local master initialized from origin/master (default!) + assertEquals(repository.resolve("origin/master"), repository + .resolve("origin/master")); + // A well known tag + assertEquals("90b818e596660b813b6fcf68f1e9e9b62c615130", repository + .resolve("refs/tags/v0.4.0").name()); + // lots of refs + assertTrue(repository.getAllRefs().size() >= 10); + // and a README in the working dir + assertTrue(new File(destRepo, "README").exists()); + assertFalse(repository.getIndex().isChanged()); + assertFalse(repository.getIndex().getEntry("README").isModified( + destRepo)); + // No project have been imported + assertEquals(0, + ResourcesPlugin.getWorkspace().getRoot().getProjects().length); + + } + + @Test + public void clonedRepositoryShouldExistOnFileSystem() throws Exception { + RepoPropertiesPage repoProperties = importWizard.openWizard(); + RepoRemoteBranchesPage remoteBranches = repoProperties + .nextToRemoteBranches("git://repo.or.cz/egit.git"); + WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy(); + workingCopy.assertWorkingCopyExists(); + } + + @Test + public void alteringSomeParametersDuringClone() throws Exception { + + File destRepo = new File(new File(ResourcesPlugin.getWorkspace() + .getRoot().getLocation().toFile().getParent(), + "junit-workspace"), "EGIT2"); + + RepoPropertiesPage repoProperties = importWizard.openWizard(); + RepoRemoteBranchesPage remoteBranches = repoProperties + .nextToRemoteBranches("git://repo.or.cz/egit.git"); + remoteBranches.deselectAllBranches(); + remoteBranches + .assertErrorMessage("At least one branch must be selected."); + remoteBranches.assertNextIsDisabled(); + + remoteBranches.selectBranches("historical/pre-eclipse"); + remoteBranches.assertNextIsEnabled(); + + WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy(); + workingCopy.setDirectory(destRepo.toString()); + workingCopy.assertBranch("historical/pre-eclipse"); + workingCopy.setRemoteName("src"); + workingCopy.doNotImportProjectsAfterClone(); + workingCopy.waitForCreate(); + + // Some random sampling to see we got something. We do not test + // the integrity of the repo here. Only a few basic properties + // we'd expect from a clone made this way, that would possibly + // not hold true given othe parameters in the GUI. + Repository repository = new Repository(new File(destRepo, ".git")); + assertNotNull(repository.resolve("src/historical/pre-eclipse")); + // we didn't clone that one + assertNull(repository.resolve("src/master")); + // and a local master initialized from origin/master (default!) + assertEquals(repository.resolve("stable"), repository + .resolve("src/stable")); + // A well known tag + assertEquals("90b818e596660b813b6fcf68f1e9e9b62c615130", repository + .resolve("refs/tags/v0.4.0").name()); + // lots of refs + assertTrue(repository.getAllRefs().size() >= 10); + } + + @Test + public void invalidHostnameFreezesDialog() throws Exception { + RepoPropertiesPage repoProperties = importWizard.openWizard(); + RepoRemoteBranchesPage remoteBranches = repoProperties + .nextToRemoteBranches("git://no.example.com/EGIT"); + remoteBranches + .assertErrorMessage("git://no.example.com/EGIT: unknown host"); + remoteBranches.assertCannotProceed(); + remoteBranches.cancel(); + } + + // TODO: Broken, seems that this takes forever and does not come back with + // an error. Perhaps set a higher timeout for this test ? + @Ignore + public void invalidPortFreezesDialog() throws Exception { + RepoPropertiesPage repoProperties = importWizard.openWizard(); + RepoRemoteBranchesPage remoteBranches = repoProperties + .nextToRemoteBranches("git://localhost:80/EGIT"); + remoteBranches + .assertErrorMessage("git://localhost:80/EGIT: not found."); + remoteBranches.assertCannotProceed(); + remoteBranches.cancel(); + } + + // TODO: Broken, seems that this takes forever and does not come back with + // an error. Perhaps set a higher timeout for this test ? + @Ignore + public void timeoutToASocketFreezesDialog() throws Exception { + RepoPropertiesPage repoProperties = importWizard.openWizard(); + RepoRemoteBranchesPage remoteBranches = repoProperties + .nextToRemoteBranches("git://www.example.com/EGIT"); + remoteBranches + .assertErrorMessage("git://www.example.com/EGIT: Connection timed out"); + remoteBranches.assertCannotProceed(); + remoteBranches.cancel(); + } + + @Before + public void setupViews() { + bot.viewByTitle("Package Explorer").show(); + importWizard = new GitImportRepoWizard(); + } + + // TODO: push this in the junit class runner. This can then be shared across + // all tests. + @BeforeClass + public static void closeWelcomePage() { + try { + bot.viewByTitle("Welcome").close(); + } catch (WidgetNotFoundException e) { + // somebody else probably closed it, lets not feel bad about it. + } + } + + // TODO: push this in the junit class runner. This can then be shared across + // all tests. + @After + public void resetWorkbench() { + new Eclipse().reset(); + } + +} diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitImportRepoWizard.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitImportRepoWizard.java new file mode 100644 index 00000000..07147142 --- /dev/null +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitImportRepoWizard.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (C) 2009, Robin Rosenberg + * Copyright (C) 2010, Ketan Padegaonkar + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.egit.ui.wizards.clone; + +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; + +public class GitImportRepoWizard { + + private static final SWTWorkbenchBot bot = new SWTWorkbenchBot(); + + // TODO: speed it up by calling the wizard using direct eclipse API. + public RepoPropertiesPage openWizard() { + bot.menu("File").menu("Import...").click(); + bot.shell("Import").activate(); + + bot.tree().expandNode("Git").select("Git Repository"); + + bot.button("Next >").click(); + + bot.shell("Import Git Repository").activate(); + + return new RepoPropertiesPage(); + } + +} diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoPropertiesPage.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoPropertiesPage.java new file mode 100644 index 00000000..27f4a045 --- /dev/null +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoPropertiesPage.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (C) 2009, Robin Rosenberg + * Copyright (C) 2010, Ketan Padegaonkar + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.egit.ui.wizards.clone; + +import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertEnabled; +import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertNotEnabled; +import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertText; +import static org.junit.Assert.assertEquals; + +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; + +public class RepoPropertiesPage { + + private static final SWTWorkbenchBot bot = new SWTWorkbenchBot(); + + public void setURI(String uri) { + uri().setText(uri); + } + + public void appendToURI(String toAppend) { + SWTBotText uri = uri(); + uri.setText(uri.getText() + toAppend); + } + + @SuppressWarnings("boxing") + public void assertSourceParams(String message, String expectHost, + String expectPath, String expectProtocol, String expectPort, + boolean enablePort, String expectUser, String expectPassword, + boolean enabledUser, boolean enabledPass) { + if (message != null) { + // TODO: magic number, looks dangerous! + assertText(message, bot.text(6)); + assertNotEnabled(bot.button("Next >")); + } else { + assertEquals("Enter the location of the source repository.", bot + .text(6).getText()); + assertEnabled(bot.button("Next >")); + } + assertText(expectHost, bot.textWithLabel("Host:")); + assertText(expectPath, bot.textWithLabel("Repository path:")); + assertText(expectProtocol, bot.comboBoxWithLabel("Protocol:")); + assertText(expectPort, bot.textWithLabel("Port:")); + assertText(expectUser, bot.textWithLabel("User:")); + assertText(expectPassword, bot.textWithLabel("Password:")); + + assertEquals(enablePort, bot.textWithLabel("Port:").isEnabled()); + assertEquals(enabledUser, bot.textWithLabel("User:").isEnabled()); + assertEquals(enabledPass, bot.label("Password:").isEnabled()); + assertEquals(enabledPass, bot.textWithLabel("Password:").isEnabled()); + } + + public void assertURI(String expected) { + assertText(expected, uri()); + } + + private SWTBotText uri() { + return bot.textWithLabel("URI:"); + } + + public RepoRemoteBranchesPage nextToRemoteBranches(String string) { + setURI(string); + bot.button("Next >").click(); + return new RepoRemoteBranchesPage(); + } +} diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoRemoteBranchesPage.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoRemoteBranchesPage.java new file mode 100644 index 00000000..cfa9fc8e --- /dev/null +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoRemoteBranchesPage.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (C) 2009, Robin Rosenberg + * Copyright (C) 2010, Ketan Padegaonkar + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.egit.ui.wizards.clone; + +import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertEnabled; +import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertNotEnabled; +import static org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled; + +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; + +public class RepoRemoteBranchesPage { + private static final SWTWorkbenchBot bot = new SWTWorkbenchBot(); + + public void assertRemoteBranches(String... branches) { + SWTBotTable table = bot.table(); + bot.waitUntil(widgetIsEnabled(table)); + for (String branch : branches) { + table.getTableItem(branch); + } + } + + public void selectBranches(String... branches) { + SWTBotTable table = bot.table(); + bot.waitUntil(widgetIsEnabled(table)); + for (String branch : branches) { + table.getTableItem(branch).check(); + } + } + + public WorkingCopyPage nextToWorkingCopy() { + bot.button("Next >").click(); + return new WorkingCopyPage(); + } + + public void deselectAllBranches() { + SWTBotTable table = bot.table(); + + bot.waitUntil(widgetIsEnabled(table)); + + int rowCount = table.rowCount(); + for (int i = 0; i < rowCount; i++) { + table.getTableItem(i).uncheck(); + } + } + + public void assertErrorMessage(String errorMessage) { + bot.text(" " + errorMessage); + } + + public void assertNextIsDisabled() { + assertNotEnabled(bot.button("Next >")); + } + + public void assertNextIsEnabled() { + assertEnabled(bot.button("Next >")); + } + + public void assertCannotProceed() { + assertEnabled(bot.button("Cancel")); + assertEnabled(bot.button("< Back")); + assertNotEnabled(bot.button("Next >")); + assertNotEnabled(bot.button("Finish")); + } + + public void cancel() { + bot.button("Cancel").click(); + } +} diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/WorkingCopyPage.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/WorkingCopyPage.java new file mode 100644 index 00000000..eb91efcb --- /dev/null +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/WorkingCopyPage.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (C) 2009, Robin Rosenberg + * Copyright (C) 2010, Ketan Padegaonkar + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.egit.ui.wizards.clone; + +import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertText; +import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellCloses; + +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; + +public class WorkingCopyPage { + + private static final SWTWorkbenchBot bot = new SWTWorkbenchBot(); + + public void assertDirectory(String localDir) { + assertText(localDir, bot.textWithLabel("Directory:")); + } + + public void assertBranch(String branch) { + assertText(branch, bot.comboBoxWithLabel("Initial branch:")); + } + + public void assertRemoteName(String remoteName) { + assertText(remoteName, bot.textWithLabel("Remote name:")); + } + + public void doNotImportProjectsAfterClone() { + bot.checkBox("Import projects after clone").deselect(); + } + + public void waitForCreate() { + bot.button("Finish").click(); + + // TODO: pass the repo url in via the constructor from the first page. + SWTBotShell shell = bot.shell("Cloning from git://repo.or.cz/egit.git"); + + // This is not a performance test. Allow lots of time to complete + bot.waitUntil(shellCloses(shell), 120000); + } + + public void assertWorkingCopyExists() { + String dirName = bot.textWithLabel("Directory:").getText(); + String message = " " + dirName + " is not an empty directory."; + // check if the text box exists + bot.text(message); + } + + public void setRemoteName(String string) { + bot.textWithLabel("Remote name:").setText(string); + } + + public void setDirectory(String string) { + bot.textWithLabel("Directory:").setText(string); + } + +} -- 2.11.4.GIT