|
@@ -103,6 +103,23 @@ type
|
|
|
published
|
|
|
procedure TestEmptyViewport;
|
|
|
procedure TestBody;
|
|
|
+ procedure TestGetStyleAttr_OneValue;
|
|
|
+ procedure TestGetStyleAttr_TwoValues;
|
|
|
+ procedure TestGetStyleAttr_OneFunction;
|
|
|
+ procedure TestGetStyleAttr_TwoFunctions;
|
|
|
+ procedure TestGetStyleAttr_NestedFunctions;
|
|
|
+ procedure TestSetStyleAttr_NewValueEmpty;
|
|
|
+ procedure TestSetStyleAttr_NewValueFirst;
|
|
|
+ procedure TestSetStyleAttr_NewValueAppend;
|
|
|
+ procedure TestSetStyleAttr_NewValueAppendSemicolon;
|
|
|
+ procedure TestSetStyleAttr_DeleteOnlyValue;
|
|
|
+ procedure TestSetStyleAttr_DeleteFirstValue;
|
|
|
+ procedure TestSetStyleAttr_DeleteLastValue;
|
|
|
+ procedure TestSetStyleAttr_DeleteMiddleValue;
|
|
|
+ procedure TestSetStyleAttr_ReplaceOnlyValue;
|
|
|
+ procedure TestSetStyleAttr_ReplaceFirstValue;
|
|
|
+ procedure TestSetStyleAttr_ReplaceLastValue;
|
|
|
+ procedure TestSetStyleAttr_ReplaceMiddleValue;
|
|
|
end;
|
|
|
|
|
|
implementation
|
|
@@ -517,6 +534,136 @@ begin
|
|
|
|
|
|
end;
|
|
|
|
|
|
+procedure TTestFresnelCSS.TestGetStyleAttr_OneValue;
|
|
|
+begin
|
|
|
+ if Viewport.Style<>'' then
|
|
|
+ Fail('20240820190117');
|
|
|
+ Viewport.Style:='padding:3px';
|
|
|
+ AssertEquals('padding:3px',Viewport.Style);
|
|
|
+ AssertEquals('3px',Viewport.GetStyleAttr('padding'));
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestGetStyleAttr_TwoValues;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left:3px; padding-top: 4px';
|
|
|
+ AssertEquals('3px',Viewport.GetStyleAttr('padding-left'));
|
|
|
+ AssertEquals('4px',Viewport.GetStyleAttr('padding-top'));
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestGetStyleAttr_OneFunction;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left:var(--bird)';
|
|
|
+ AssertEquals('var(--bird)',Viewport.GetStyleAttr('padding-left'));
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestGetStyleAttr_TwoFunctions;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left:var(--bird); padding-right: min(10px, 20%) ';
|
|
|
+ AssertEquals('var(--bird)',Viewport.GetStyleAttr('padding-left'));
|
|
|
+ AssertEquals('min(10px, 20%)',Viewport.GetStyleAttr('padding-right'));
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestGetStyleAttr_NestedFunctions;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left: calc(var(--bird)*10%) ; padding-right: min(max(10%,3em), 20%) min(3px,5ch)';
|
|
|
+ AssertEquals('calc(var(--bird)*10%)',Viewport.GetStyleAttr('padding-left'));
|
|
|
+ AssertEquals('min(max(10%,3em), 20%) min(3px,5ch)',Viewport.GetStyleAttr('padding-right'));
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestSetStyleAttr_NewValueEmpty;
|
|
|
+begin
|
|
|
+ if not Viewport.SetStyleAttr('padding-left','') then
|
|
|
+ Fail('20240820193346');
|
|
|
+ AssertEquals('',Viewport.Style);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestSetStyleAttr_NewValueFirst;
|
|
|
+begin
|
|
|
+ if not Viewport.SetStyleAttr('padding-left','3px') then
|
|
|
+ Fail('20240820193354');
|
|
|
+ AssertEquals('padding-left:3px',Viewport.Style);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestSetStyleAttr_NewValueAppend;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left:4px';
|
|
|
+ if not Viewport.SetStyleAttr('padding-right','7px') then
|
|
|
+ Fail('20240820193401');
|
|
|
+ AssertEquals('padding-left:4px; padding-right:7px',Viewport.Style);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestSetStyleAttr_NewValueAppendSemicolon;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left:4px ;';
|
|
|
+ if not Viewport.SetStyleAttr('padding-right','7px') then
|
|
|
+ Fail('20240820194710');
|
|
|
+ AssertEquals('padding-left:4px ; padding-right:7px',Viewport.Style);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestSetStyleAttr_DeleteOnlyValue;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left:4px';
|
|
|
+ if not Viewport.SetStyleAttr('padding-left','') then
|
|
|
+ Fail('20240820193844');
|
|
|
+ AssertEquals('',Viewport.Style);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestSetStyleAttr_DeleteFirstValue;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left:4px; padding-top:3px';
|
|
|
+ if not Viewport.SetStyleAttr('padding-left','') then
|
|
|
+ Fail('20240820193847');
|
|
|
+ AssertEquals('padding-top:3px',Viewport.Style);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestSetStyleAttr_DeleteLastValue;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left:4px ; padding-top:3px';
|
|
|
+ if not Viewport.SetStyleAttr('padding-top','') then
|
|
|
+ Fail('20240820194509');
|
|
|
+ AssertEquals('padding-left:4px ;',Viewport.Style);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestSetStyleAttr_DeleteMiddleValue;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left:4px ; padding-top:3px; padding-right: 2px';
|
|
|
+ if not Viewport.SetStyleAttr('padding-top','') then
|
|
|
+ Fail('20240820195100');
|
|
|
+ AssertEquals('padding-left:4px ;padding-right: 2px',Viewport.Style);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestSetStyleAttr_ReplaceOnlyValue;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left: 4px;';
|
|
|
+ if not Viewport.SetStyleAttr('padding-left','5em') then
|
|
|
+ Fail('20240820195245');
|
|
|
+ AssertEquals('padding-left:5em;',Viewport.Style);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestSetStyleAttr_ReplaceFirstValue;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left: 4px ; padding-top:3px';
|
|
|
+ if not Viewport.SetStyleAttr('padding-left','7em') then
|
|
|
+ Fail('20240820195924');
|
|
|
+ AssertEquals('padding-left:7em; padding-top:3px',Viewport.Style);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestSetStyleAttr_ReplaceLastValue;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left: 4px ; padding-top: 3px ';
|
|
|
+ if not Viewport.SetStyleAttr('padding-top','7em') then
|
|
|
+ Fail('20240820200021');
|
|
|
+ AssertEquals('padding-left: 4px ; padding-top:7em',Viewport.Style);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFresnelCSS.TestSetStyleAttr_ReplaceMiddleValue;
|
|
|
+begin
|
|
|
+ Viewport.Style:='padding-left:4px ; padding-top: 3px ; padding-right: 2px';
|
|
|
+ if not Viewport.SetStyleAttr('padding-top','7em') then
|
|
|
+ Fail('20240820200135');
|
|
|
+ AssertEquals('padding-left:4px ; padding-top:7em; padding-right: 2px',Viewport.Style);
|
|
|
+end;
|
|
|
+
|
|
|
Initialization
|
|
|
RegisterTests([TTestFresnelCSS]);
|
|
|
end.
|