mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 04:08:27 +08:00
* added a picture for pull from zip it can then be used in guide-import-zip.md * Fix for Issue 2922 https://github.com/larshp/abapGit/issues/2922 Added a new test method find_head_closing_tag. Implemented fix in method zcl_abapgit_gui_html_processor->find_head_offset. * Removed dont needed Pull_from_zip.png Removed dont needed Pull_from_zip.png * Restored NewLines handling in patch_html Restored NewLines handling in patch_html * Fixed some abapLint Warnings Fixed some abapLint Warnings * Fixed some abapLint messages Fixed some abapLint messages
This commit is contained in:
parent
dcb4d94275
commit
17a67933e3
|
@ -40,6 +40,14 @@ CLASS zcl_abapgit_gui_html_processor DEFINITION
|
|||
RETURNING
|
||||
VALUE(rv_yes) TYPE abap_bool.
|
||||
|
||||
METHODS find_head_offset
|
||||
IMPORTING
|
||||
iv_html TYPE string
|
||||
RETURNING
|
||||
VALUE(rv_head_end) TYPE i
|
||||
RAISING
|
||||
zcx_abapgit_exception.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
@ -77,10 +85,7 @@ CLASS ZCL_ABAPGIT_GUI_HTML_PROCESSOR IMPLEMENTATION.
|
|||
|
||||
CLEAR: ev_html, et_css_urls.
|
||||
|
||||
lv_head_end = find( val = iv_html regex = |{ cl_abap_char_utilities=>newline }?\\s*</head>| case = abap_false ).
|
||||
IF lv_head_end <= 0.
|
||||
zcx_abapgit_exception=>raise( 'HTML preprocessor: </head> not found' ).
|
||||
ENDIF.
|
||||
lv_head_end = find_head_offset( iv_html ).
|
||||
|
||||
CREATE OBJECT lo_css_re
|
||||
EXPORTING
|
||||
|
@ -153,4 +158,17 @@ CLASS ZCL_ABAPGIT_GUI_HTML_PROCESSOR IMPLEMENTATION.
|
|||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD find_head_offset.
|
||||
|
||||
rv_head_end = find( val = iv_html regex = |{ cl_abap_char_utilities=>newline }?\\s*</head>| case = abap_false ).
|
||||
IF rv_head_end <= 0.
|
||||
rv_head_end = find( val = iv_html regex = |</head>| case = abap_false ).
|
||||
IF rv_head_end <= 0.
|
||||
zcx_abapgit_exception=>raise( 'HTML preprocessor: </head> not found' ).
|
||||
ENDIF.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
|
|
@ -2,7 +2,7 @@ CLASS lcl_gui_mock DEFINITION.
|
|||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_cache_signature,
|
||||
url TYPE string,
|
||||
url TYPE string,
|
||||
type TYPE string,
|
||||
data TYPE string,
|
||||
END OF ty_cache_signature.
|
||||
|
@ -19,6 +19,10 @@ CLASS lcl_gui_mock IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltcl_html_processor_test DEFINITION DEFERRED.
|
||||
CLASS zcl_abapgit_gui_html_processor DEFINITION LOCAL FRIENDS ltcl_html_processor_test.
|
||||
|
||||
CLASS ltcl_html_processor_test DEFINITION
|
||||
FOR TESTING
|
||||
DURATION SHORT
|
||||
|
@ -32,7 +36,7 @@ CLASS ltcl_html_processor_test DEFINITION
|
|||
|
||||
METHODS render_html
|
||||
IMPORTING
|
||||
iv_src TYPE string
|
||||
iv_src TYPE string
|
||||
RETURNING
|
||||
VALUE(rv_html) TYPE string.
|
||||
|
||||
|
@ -41,7 +45,7 @@ CLASS ltcl_html_processor_test DEFINITION
|
|||
METHODS process_with_preserve FOR TESTING RAISING zcx_abapgit_exception.
|
||||
METHODS process_no_css FOR TESTING RAISING zcx_abapgit_exception.
|
||||
METHODS process_fails FOR TESTING RAISING zcx_abapgit_exception.
|
||||
|
||||
METHODS find_head_closing_tag FOR TESTING RAISING zcx_abapgit_exception.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS ltcl_html_processor_test IMPLEMENTATION.
|
||||
|
@ -105,7 +109,7 @@ CLASS ltcl_html_processor_test IMPLEMENTATION.
|
|||
`</html>\n`
|
||||
) ).
|
||||
|
||||
" GUI call checks
|
||||
" GUI call checks
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = mo_gui_mock->ms_last_cache_signature-url
|
||||
exp = 'css/bundle.css' ).
|
||||
|
@ -173,4 +177,30 @@ CLASS ltcl_html_processor_test IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD find_head_closing_tag.
|
||||
"given
|
||||
DATA: lv_head_end TYPE i,
|
||||
lv_html TYPE string.
|
||||
|
||||
lv_html = '<!DOCTYPE html><html><head><title>abapGit</title><link rel="stylesheet" type="text/css" ' &&
|
||||
'href="css/common.css"><link rel="stylesheet" type="text/css" href="css/ag-icons.css">' &&
|
||||
'<link rel="stylesheet" type="text/css" href="css/theme-default.css"><script type="text/javascript"' &&
|
||||
' src="js/common.js"></script></head>'.
|
||||
|
||||
"when
|
||||
TRY.
|
||||
lv_head_end = mo_cut->find_head_offset( iv_html = lv_html ).
|
||||
CATCH zcx_abapgit_exception.
|
||||
cl_abap_unit_assert=>fail( msg = 'HEAD closing tag could not be found' ).
|
||||
ENDTRY.
|
||||
|
||||
"then
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = lv_head_end
|
||||
exp = 299
|
||||
msg = 'Head closing tag was not found' ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
|
Loading…
Reference in New Issue
Block a user