From 527dd3005eb6379010af941dc2d86fc64203ce74 Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Fri, 25 Mar 2022 20:17:06 +0800 Subject: [PATCH 01/15] fix test fix test --- .idea/workspace.xml | 74 ++++++++++++++++--------- test/gui_test/calculator/calculator.py | 2 + test/test_source/1.png | Bin 415 -> 270 bytes test/test_source/2.png | Bin 659 -> 405 bytes test/test_source/3.png | Bin 658 -> 412 bytes test/test_source/4.png | Bin 509 -> 341 bytes test/test_source/5.png | Bin 574 -> 368 bytes test/test_source/6.png | Bin 591 -> 400 bytes test/test_source/7.png | Bin 481 -> 331 bytes test/test_source/8.png | Bin 676 -> 422 bytes test/test_source/9.png | Bin 617 -> 409 bytes test/test_source/equal.png | Bin 356 -> 223 bytes test/test_source/minus.png | Bin 305 -> 187 bytes test/test_source/multiply.png | Bin 490 -> 0 bytes test/test_source/plus.png | Bin 411 -> 248 bytes 15 files changed, 49 insertions(+), 27 deletions(-) delete mode 100644 test/test_source/multiply.png diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c02c35a9..5343862f 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,8 +2,22 @@ + - + + + + + + + + + + + + + + + - @@ -74,7 +88,7 @@ - + - + - + - + - + - + @@ -340,6 +354,11 @@ + + + + + @@ -377,7 +396,7 @@ - + @@ -399,6 +418,7 @@ + diff --git a/test/gui_test/calculator/calculator.py b/test/gui_test/calculator/calculator.py index 0f3bf578..a3bf29fd 100644 --- a/test/gui_test/calculator/calculator.py +++ b/test/gui_test/calculator/calculator.py @@ -1,3 +1,4 @@ +import os import subprocess from time import sleep @@ -10,6 +11,7 @@ """ subprocess.Popen("calc", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=True) sleep(3) + locate_and_click( "../../test_source/1.png", mouse_keycode="mouse_left", diff --git a/test/test_source/1.png b/test/test_source/1.png index 4e6ff405b6886abbde27d81e57e6095f95d14ec6..87ebb02e3537939e662dc13b49963a2b62b5230f 100644 GIT binary patch delta 228 zcmbQw+{dKY8Q|y6%O%Cdz`(%k>ERLtq_u%qi-QeBGA>G;sAy8pu-MbZF(ktM?Ty{M zM-&8HFMizS$Uen^QKiI%bqkv$b68S`IOs6CGo!GBStx) Szn%ac&fw|l=d#Wzp$P!N-&=S9 literal 415 zcmeAS@N?(olHy`uVBq!ia0vp^ML_Js!3HEZu6?`!NHG=%xjQkeJ16rJ$YDu$^mPPE z^>hD8WCij$3p^r=85sBugD~Uq{1quc4JMv0jv*CsZ|`j6Z8i{axaiH+$oN7tW5SK5 zHb;qeMhQkOsbdMuY936xRDb+jzp+Mdzs}B2uRjY{?I~YZW#Q~3A#`YhKwFD}N{gZ* z4`-qW2YEt`{5y5LLqbJ=?|a_DDgDW!PvW>?TVls&o8nWg+?99tXeV4YG4u`g`&poP zy>u`0wA9M=xwoHjO6#TE|897`IOn!l?DeNp_{BGAbgg)8RsNs(_l=+CxSVCL;as6i dwrd5I_61GS3i|H-qZ1gY44$rjF6*2UngAxXiVy$* diff --git a/test/test_source/2.png b/test/test_source/2.png index ad5d8deb1917a4917697c27e55afef31d2f1fbb6..4b1207d3180a368a88cc2e18ce1cb42111b3633c 100644 GIT binary patch delta 364 zcmV-y0h9id1(gFKiBL{Q4GJ0x0000DNk~Le0000h0000X2nGNE06@l4rja2ue*r2< zL_t(oN9~urjf5}|M(3^rVn|64F)74Q0u?|9bN~eqBSDU!00KfX0wAXWBr5Q(tvPA$ zCpymrEBQ&533fi`XLZ)dj`Ht(l z>fEJ5OEyhYnCBTszv=rPf*`<=KISRTg^}gL$Z}z1xiGRk06YMMb+_tOJh{UF0000< KMNUMnLSTaM9+`sx literal 659 zcmeAS@N?(olHy`uVBq!ia0vp^sX*+{!3HEhd2`PPQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$Aj3=B*fo-U3d6>)Fx*sn`WlsNt|J&k$MrHxE) z8g4Z6E!Fs=X)2~5$Q{5H*1)^q%7U<)3{@w6=9#~{GyCKnpWn9cf7S|B_B)sEuRLFQ zfAS9dxb@fdg{RDaALt;$>JivLMPgC!rnvQMuVzIq4B%KFv@&J!#S?kkZ~vB#x%hX_ zySn|i6AU)|t&_hOt~J$Q-ud)uyZO^jrsV9t8)Y}2|9R)4?n|$~=4`$hvHkYevfa5i zbIj&^kGTBuO4#a9j;%3zhbtFpq@Q|OvMFlqH@nX#?N^7bPCWLb+^*@OOS%6?`!D;O zEdH;F(QAMF`m2=NqAP3n$@RNS6z`0Y=nN7)8XhHSC2CypjH#+KH0R4tR~KfZzGo5H^Qk29V4A1&&A z)F1ikYn8>k^Uuv>_zo8exkw&u{_^{8!OljezJd}e)Qt|;7J;$*1uE&MHE~a ggUBZi8vf>G2whfqaA&t4Fd;E`y85}Sb4q9e0D(jh*Z=?k diff --git a/test/test_source/3.png b/test/test_source/3.png index b57c99a586e2235b664ec9a9278bb1794febe612..1fbaf12c951f669ea9999cf339dff1ac8bdbda23 100644 GIT binary patch delta 371 zcmbQlI)_=YGr-TCmrII^fq{Y7)59eQNUH;}8V4JYbpPKpVWOf*J)@zgi(^QH``Z~C z*R~k&IMmiNXH9sqQjnFE=K!C_l#nYq2bgpiY?ByYXe2OHNievbm|MK;$NnvrFTYGx zcilMmndU*R4*~iQyninIscl#k(<39UeEjH%LNIgse_iuFWff1RzQ->bKW@_5qUEg8 zE|fXTNyPO+sjP|b;@9<&(+=)?Zza~KKU=8p@q!n;&$i{R-nDM!A@`a!(^3P!Jj>U6 z_^mDCdg%Fm?_WoyIqz%6?Xb#u%U7*hBr3VR=0U>rxFdx;u7M5$EFppmMDvqw zo89HOAy9iic?DER*Sasivo}gY^lf z-9r8RyG3@FO0Z3RzO(L`!8D~whi^X+a#57gXkS#G@Na4X!e<{DDwt9fmw(PVGgqsJGTSBZyY$sZE&221mnnje}w)^O! z-g!H3uK03l{pFW`?szP{oEcqzFKDHJndZ~1@7FI+j(flMdbXtu-?nA$muu|K|Gu(c pZ$__{N)Ok86%1q$zsi*E-+sS$wpQl-UBGn2;OXk;vd$@?2>^5F9mxOy diff --git a/test/test_source/4.png b/test/test_source/4.png index 95e38c925d7aa92bea63bc7133911321f8fa2a93..98d71434204b7231caa3ecadb2456025d43a3090 100644 GIT binary patch delta 300 zcmV+{0n`5d1Jwc{iBL{Q4GJ0x0000DNk~Le0000V0000Z2nGNE0Bjb~?~x%ie*o%9 zL_t(oN9~s}3WP8aMQ69RvDUi?9wAq-6LSF5>jeZ4kb~H3Wo_vNas+oLOetu_g()@< zB+OTMFq4SBjxQj@n^qB`T!bhWA<9LFauL{aV+`bZ4$HDo5)Mng?>ks)sp7+uw`~hW zQBcJvSUyb?tm_I@RZ+qxNbZ~if2}nP!vIN=P|7Dr-ZYJGcUhK{Jma=}97o^ouIngy z&Mi64x$k@5?les)ea@vEj}^`t+l_O^bB))wZT>#4_zZ{3PiGVNn{1`ISV`@iy0XB4ude`@%$AjKn;^TT^vIy;@;je>}n1WX?T-!4Hzz`0R^>qvk?8R7?5`L);7`epG%UKyE>ctDp$_)7GQa_Yn|WQEg35`x>B~^ zKKZrkYUf@t?$oezdk%Cj5;$I1lC|E|X>Z*6%%^829{656_g3z=fY|FNf7Z-9=My>Y z<(0b4ZLfaE9Wt1bD6#D7?L(*bo|V$_ob+;U$h4(0eC%`c4(G^Ey8FI-=iR)^U*pr& zil-UbZ=Uo_{P@OD!*rlEXZIWk>_6_@cYN`^zxAtYXZ_&IoVVok(?!A6I%R#gq`)4Z l@8A5xg@k|r2baqe@t^mTZ+5)oybp{r22WQ%mvv4FO#o(@)`|cC diff --git a/test/test_source/5.png b/test/test_source/5.png index b8227604d6aedc7fb1403c0cbad0952b6bbb99b3..05bb43a661a7db395a789f8886a7bf0eedbe788f 100644 GIT binary patch delta 326 zcmV-M0lEIZ1n>eOiBL{Q4GJ0x0000DNk~Le0000T0000R2nGNE0D#Jb5|JS_e+5ZI zK~zXf?UuU@gD?<=FPQ=f!~l!{1rlSx1dPBGR4@RDhK_;~Bnk=!fEp?~Xy~2TIi*O7 z96>}#;ge4G*_MAl&L>~k9r!UMR~I@3~>Y<@{{3{CrJXn?_TSRrH8(Q3^p2Fx$4#+s3i)f3&V^tZir2POGYV29V=8P?jb3tb-g#UDv^~ETTS+ zBcy3677;}eSe7N)sccI4e7AkyuRi)sfn*p448wpPo#RIDJkP>j$@3gc(?o9t{7ygN zc^=bsoyBp?nxa~60+7BevL9R^{>5*BkmI;PPS1VRa_t@NwIR)w6yF@9VHU zcIa>2f03r27p6K$$n+dMNGx&Y-}0L;OP-Wiy?nX+^wUMw`)BaRtqfTbq2skS?DFjJ z?xRlSb%wHgu4YwAe>4BX$8IcX;~RYUX0p+bpEYIKTcb)>t1jCg)TD4>uB@8;EYC?E z>#twF?EFn2*KGEsw`EH&X1rKie}-+o-}0)e8}GmG5}tWBO{i_*ygx~0IyKX6J+8mr z>Z2xHelN!?uI^H?vDh>()y_p8ZHE_HA1{0pcK=Bp-}>vX^Y+HA&-?28uIcx=ln?vs ze!MBO-u}yK@oesWck`Cs&D-ty^ls74DL-r8#btf{UAy;d_fAb!Zab;oCuO_$?$Nc8 z>p#EyW5t<`AM8{4k6g`CZ9n|*r{AC7?dKB=CKT;_^R8yfY|A@bewqn9e8(P8NT_~d ZEm3W`@nz$MlfXD<@O1TaS?83{1OSJ)2xR~O diff --git a/test/test_source/6.png b/test/test_source/6.png index 94b08744eb3cd1183d34f5d02fde422a1d4011df..797d92976fffe17aca6d54e27d935e1182b5a1c0 100644 GIT binary patch delta 358 zcmV-s0h#{K1dszEiBL{Q4GJ0x0000DNk~Le0000X0000V2nGNE0BMw@vXLP*eh13B87z14#5LC*TIIgIZicq2K^|8lA)m_M0`^{~bU1&Aw#A zj!nGG%x-vz3-~i{y8aa-p)e8(BcU)73L~K~5{gF>%d$XOmf$#!9C@C@JkRv>d)N{v zkYyR1=LvOPL)UfSc^>ThPAfFPfA0wnQ51=yC}{Q!mPFt8!nSR(t}8{J!79fzO%MbD zxUNf)XRsu$3`mK#Z6S_h*_3$2ISa~&7QXMxo=DSFmgdTgsH#eqsA(En^*t;Jd>M)y z$3c-B6v4PIta4x}!Y~BOvM6$cWx*}03rhmegI~guNRkAGVSsJhC~`B7JfqB#HdGdE zuqm-QRb%48g}s9Jy09g%DbQR+iQbRVzW4g$f=eLV?*|xGw%=>U45atZ8U*Qj}_)=hhkbXz$E7 zqH(tRyN!w`on3P`w{Nd?vHADcb^Gld6z;2aIUilR@X@7!!ps#rOhRI$wDfpIr?+)^ zBZMu~mtW?zs-MfJGTD=Zt@%pSTCtq%(VGw1y@?OvYiFL~rMly8-h)WAql@&6_Q_dqdatEYpa!VFnUB z3iHp;4m3}+e!SzhM(^`mrI{_hHGAWNeU@JqiEa0lnJgv5)%v2|CRyyeQI+2G#h>2_ zt?9Sgbo=ds2pv25-x(%el6&LUJFmaK*wnA#Wbfjsr=Papf4|&JhVT9}v)N~rW%w@3 ze2agcWBN^eM%LC}VaEj4+&-H&`Pb%~J&SU09OZ6pdbwA)|F~wA`ysP8kLEMYu22zL zSYbC`a~I$23azP&EN1#>{5x7>eS6)NO0z-O_^AAR(b{lV<$#TOeK6cWO2w#WVn jzEGrw9@0B>80r{S9_u=`g3rhr81)REu6{1-oD!M`r0SbjD;T|k)#*nOFrX-ko z<`3WS20|J>#|ga17xOhlKm58=$vMht9X|N&U z1-MMpbSR}la)~;Q>$(of-rf^5cNjdey@&l3IOm`!3eZ|(!vsZ0Y}*#L@45~fKCCCu zwk;${0##LE!-pl%_x&R`_mBnFb%pa4Kv|a9#6cDqh9RUeCS)vRfpHum&vU$rhb*ux n%cBDFVNn{1`ISV`@iy0XB4ude`@%$AjKn-P{E{-7?&TnrTb{%pMIredTb@P`;j9a`V zyQh>@F&wm-P+igS<=ZWG#|@jj=c+mVQc=HgxAIKcYWWjq4)NSyUs-s{Uf*$2|9W{R z|Jqxg{ssaE92l4xd00qduzXJ~HJg2N_4Q9S(;t7#sNbun5++&7|I6^|Fo?E0*vP-09!SBC%zL!s=ZJzkECeQyar`?5@ zC6{)_tuNgr_Q$zuXUr)R-%H>3+7@cR;N2CYCw2Tz+&&iB73;F+MoxSAMe&8h_1B^4 zvzA%aa+qB(;Q4j`c!Z7^h!b#oo7LHB`T2{g?>>yWaDKsm>|wE2dL~Ox7srr_xVJO+ zuils_aeRGon(AcEZqHBr8maDHUMK7q^suejG;AqGOY+KSV?1Mcw}3oiWQC z6dc+QH;Q$$R_=|P<+og<(`8Qn?1NS-J6)RmmJ5HavOSezbmvUvmfUk&|2Alyt!WZQ{ADp@$19=f+JL~zW-jFwEbU8 zG=KZyImd5H`8yqrd02x zw9OAq`Bvs_&yHC&wK&U0?)edkt1n9;G#u`32}ro=cT{g}h}M?-?|&K|-_td%;j-N4 z%>DPDi!+`utM3f8E;XC|S1@Y*^+*keq~5yj-^~XbUIT4^m16YJXKB!!`zO;j&pG{c z(q)k_&r)}_{^N&#+HZ*VO_~}~zT^JevN`v6#^}wN!Q_)P^-9vl6F0NAX6(NEX)E`& z70oqv=QFupKMVPD#9XTPhm^Ir{1(>jrVln`ZNFWU%k_E*(;na8wPCC4-PHGRJSnpD yQk(2|R3^;p@7sv0!MToD;|nReu1t6S!g*`ug;$CKJMRKh6oaR$pUXO@geCyWxhvZM diff --git a/test/test_source/9.png b/test/test_source/9.png index 23370eb7e57195e8fe02047939afbf99c690de3c..ffc4b604f89ec2d3624df874834589740bcf6eda 100644 GIT binary patch delta 367 zcmV-#0g(Rb1epUNiBL{Q4GJ0x0000DNk~Le0000R0000X2nGNE04O!ko{=Fne=bQx zK~zXf?UqfBML-aMYvu-a5)ykyu(4)ug9~s2PT&GA;GMt$*jcc%V9x>koS@&UN>4J2 ziK#auR=%WDtt9>Fu5NsY7jO}uGG4+hJB3?z3b*VOZW%GpGo)z>x~@|Tf&j*Gly`rJ zEnC+W9LIsa@1ZCPYKZ4~^bjoYe-pzYNfKe2rdXCmW(4&u%c6T6*fX1^32fU2MNwo1 zsEJD{VF=r{QLO8l29M*Ia)_#` z6c3TLV=)Yaa9vkunns%?%QEqJJm{LkTe6?X^PI#S{=Gr4X1GgPNa>$wMcbB^5F-b+ z4C~|jzNo5-2LD<JB15n08d-tmYFSbC^`TD N002ovPDHLkV1j>Gp8)^> literal 617 zcmeAS@N?(olHy`uVBq!ia0vp^4nSanMpoV{*E{-7?&TnUK%wlpBXj89b%+1|%&M9ES zhO6oUIV_Hj@dv~MHe41Ls6HyJqvPVJ!{WF>h+Fr~SJoqO9y1dCgeDu!7EH6V*mt{h z_TTq+ZeHE~`|m%-uFCY)N0}0E<4T6zscIMOJecglHXn zTekS*<5CNm6|!8d2{v-hHgeA|8d-2ZsM_mfHhbyGGAmh)>8Jm2UXXt9+ioxK=bv+` zQwzR{M(Bu{{PbG-Dfg4d?z?S1YRtzU3zqGc{eJ3!PQ%k8PdyQ?C+S^Bl`8k&pS)CH zHPb|omOXd#P6kCtru?_;bZN4g>v!_}n(Nv7CLfJti1;TE^VWT_;9d5F-Pd0idW$Xp z-EcF9?Q7NCcg?j2e%37G_D)`WaY2@W3}0psi{JHz8aw{UCs~Si%J^1ozIlOd#r^lr zI%10rFJ?^9X}uAjyo2pZ)>ir1Oa8m9;aU@>U8FTt$@`%R!yUf=Z1V)0)^7L`c_5Nu z2g9St2bHV4-!5?45~aII<=nM~^`Z>(ODtsSLKv3ZetSttv-h&A!2E9s1{HIDY+y>b zxjJn11i$4g{iQZ)ebDL%Z45t%FU-;8T!9H@zU7DQ!q1g&>H(7ngQu&X%Q~loCIB*( B3Qqt4 diff --git a/test/test_source/equal.png b/test/test_source/equal.png index 62601aa92552004dce3997cc631bd0957c4043e3..06ea84f372cda00d317165fc89e30b2bce509ac5 100644 GIT binary patch delta 180 zcmaFDbe~bNGr-TCmrII^fq{Y7)59eQNXrAUEC(Bq3`*N>G*QvCzQohTF~q|=ImN^N z!~Dbs2H`1k0tQ(>8yW&nv$OO>*(oGA=&DC-lh-#-5qOr?`l*9CfB(O<4R37tpFU(` z(d9Q6Oci*Z+zb@gxBr_IQTfbtO1pH=ov7Rb_TLR^7Ew(Xh4LH@ta!@Izopr0A_$XNdN!< literal 356 zcmeAS@N?(olHy`uVBq!ia0vp^NkHtx!3HGPa57r}DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheoCO|{#S9F5he4R}c>anMpx{qW7srr_xVN`A1~NGaI9xm|H{puX0ll8o zj01W+I&F`CL^p*vZFHaj^d6*<JCX{POXW$+p?YE$_Z7_$m8-{{7;jLdCf2r#Du|oqbvM`}28=y1!>nUX{0Uv1SV7 wa8VS{&31XNy=XP(#XbiSh)65Zj6)Ltf9zE6sL~Z*2@C`VPgg&ebxsLQ0OPTBP5=M^ diff --git a/test/test_source/minus.png b/test/test_source/minus.png index 80b0e6b78befd6d5b619a682db17bc402179447f..36dba2e87ced21b3b17e8dbf8556d6d37076cd8c 100644 GIT binary patch delta 143 zcmdnUw3|_}Gr-TCmrII^fq{Y7)59eQNJ{~+Fb5lu>~oc6o2Y1-8sO>T7~a~60+7BevL9R^{>oK};uUdBY-Yvo9--_>l&u{s8PIAeCh{laf$*jk?dPF6(4Z;%E5HAo{8CxlH zyvBCB&gmQ5a`W!JW{SUV`mJ{U?c&$F`aat{e^x5r^Oc=svsW7a+x1pb+;ER#70^cv Mp00i_>zopr0RDY&F#rGn diff --git a/test/test_source/multiply.png b/test/test_source/multiply.png deleted file mode 100644 index 973320a2ec09837721fd02cedc337e49acc25c42..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 490 zcmeAS@N?(olHy`uVBq!ia0vp^oa~60+7BevL9R^{>rzId^3b zmOiBy4MG_Vu1=yR3~bHE9tvn&$WAcsU``=E= zDG3QoZ0KNdQBhE06y)siaByKFNoWbz%G~J9xwC7F&ChRs`TO3!pWdQD*GrdaaB+Aw ze6lfrY;jApex*~^tYgN|Gm59;>QE-S`+_SAD!^=K=`W(^ZI^nUl5|GSbRY`V3pZB6;HXwcd?Hh zMO>Gy%ijG;J=Eiq>e0fS`*%36?0c_1<@}ZNo>D>9Oc`B-LLmLvA0{8MeSL4Lx8DKA O4}+(xpUXO@geCxd=)R!< diff --git a/test/test_source/plus.png b/test/test_source/plus.png index 0aab0fc104e57c6baf98fc03dd64f71ab1187332..8197e13c8af30b9e629b4b6f00229c42dad9dbd7 100644 GIT binary patch delta 206 zcmV;<05SiY1NZ?UiBL{Q4GJ0x0000DNk~Le0000d0000P2nGNE0J76J=#e2be*le1 zL_t(oN9~ru34kyRMWYLJgNiO9y0PLsid~@erXVPVTm=pP5NO_|X;1I)KWTNG*G)>P z`BaI?Nhw1v#>f*6nA|w@JmG-JrIdKWVTF*QTJHDy%B{@d|B^B198L2=-g|!e2W+=? zZA0s}^9_S#PD&YaIs9l~g$N;tBwP80{e-2MoD`FjqF9dT0kokhS^fzWB>(^b07*qo IM6N<$g3x+azW@LL literal 411 zcmeAS@N?(olHy`uVBq!ia0vp^(Ln6V!3HE%U(G54QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjKn(_-E{-7;ac}P|>}_$7aClgMU1`IXhJ_4X z2LhNTIjv~QD$ro*Yw-)%zBA=a>SW(*d!#3Qm;B*wXUI6|VPWibe~ynn;fy`JMrJ2& zC?q$N%+UCK%1?2Keef+_WtE5+u!gT@E#V(y?xB0FZ1cX zJDVNh#vEfy{r}?oZ{6LiR^8sSqvlaRlS7^|$qw%AtY8#3G Date: Sun, 27 Mar 2022 00:28:51 +0800 Subject: [PATCH 02/15] update dev version add test total record upload dev version --- .idea/workspace.xml | 112 ++++-------- dev_setup.py | 2 +- je_auto_control/__init__.py | 2 +- .../utils/executor/action_executor.py | 15 +- .../utils/test_record/record_test_class.py | 22 +++ .../test_record/record_test_result_class.py | 13 -- je_auto_control/wrapper/auto_control_image.py | 91 ++++++---- .../wrapper/auto_control_keyboard.py | 161 ++++++++++------- je_auto_control/wrapper/auto_control_mouse.py | 170 +++++++++++------- .../wrapper/auto_control_record.py | 43 +++-- .../wrapper/auto_control_screen.py | 26 ++- 11 files changed, 375 insertions(+), 282 deletions(-) create mode 100644 je_auto_control/utils/test_record/record_test_class.py delete mode 100644 je_auto_control/utils/test_record/record_test_result_class.py diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5343862f..c7c05311 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,22 +2,15 @@ - - - - - - - - - - - - - - - + + + + + + + + @@ -81,14 +74,14 @@ + - - + - - - - + - + - + - - - @@ -358,7 +303,7 @@ - + @@ -396,7 +341,8 @@ - + + @@ -416,6 +362,7 @@ + @@ -429,6 +376,7 @@ + @@ -442,6 +390,7 @@ + @@ -460,6 +409,7 @@ + diff --git a/dev_setup.py b/dev_setup.py index 009a708a..1af24a01 100644 --- a/dev_setup.py +++ b/dev_setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="je_auto_control_dev", - version="0.0.08", + version="0.0.09", author="JE-Chen", author_email="zenmailman@gmail.com", description="auto testing", diff --git a/je_auto_control/__init__.py b/je_auto_control/__init__.py index 70a60fdb..90fd057f 100644 --- a/je_auto_control/__init__.py +++ b/je_auto_control/__init__.py @@ -57,7 +57,7 @@ # timeout from je_auto_control.utils.timeout.multiprocess_timeout import multiprocess_timeout # test record -from je_auto_control.utils.test_record.record_test_result_class import test_record +from je_auto_control.utils.test_record.record_test_class import test_record # utils image from je_auto_control.wrapper.auto_control_image import screenshot diff --git a/je_auto_control/utils/executor/action_executor.py b/je_auto_control/utils/executor/action_executor.py index 513337c9..563a6f2a 100644 --- a/je_auto_control/utils/executor/action_executor.py +++ b/je_auto_control/utils/executor/action_executor.py @@ -25,7 +25,7 @@ from je_auto_control.utils.exception.exception_tag import cant_execute_action_error from je_auto_control.utils.exception.exceptions import AutoControlActionException -from je_auto_control.utils.test_record.record_test_result_class import test_record +from je_auto_control.utils.test_record.record_test_class import test_record event_dict = { # mouse @@ -60,9 +60,9 @@ def execute_event(action: list): event = event_dict.get(action[0]) if len(action) == 2: - event(**action[1]) + return event(**action[1]) elif len(action) == 1: - event() + return event() else: raise AutoControlActionException(cant_execute_action_error) @@ -73,6 +73,13 @@ def execute_action(action_list: list): :param action_list the list include action for loop the list and execute action """ + flag = test_record.init_total_record + """ + if init_total_record original is True + make it False and then make it return + """ + if flag: + test_record.init_total_record = False execute_record_string = "" if action_list is None: raise AutoControlActionNullException(action_is_null_error) @@ -86,4 +93,6 @@ def execute_action(action_list: list): except Exception as error: print(repr(error), file=sys.stderr) test_record.error_record_list.append([action, repr(error)]) + if flag: + test_record.init_total_record = True return execute_record_string diff --git a/je_auto_control/utils/test_record/record_test_class.py b/je_auto_control/utils/test_record/record_test_class.py new file mode 100644 index 00000000..e9c1fb0c --- /dev/null +++ b/je_auto_control/utils/test_record/record_test_class.py @@ -0,0 +1,22 @@ +class TestRecord(object): + + def __init__(self, init_total_record: bool = False): + self.init_total_record = init_total_record + self.record_list = list() + self.error_record_list = list() + self.total_record_list = list() + + def clean_record(self): + self.record_list = list() + self.error_record_list = list() + self.total_record_list = list() + + +test_record = TestRecord() + + +def record_total(function_name: str, local_param, program_exception: str = None): + if not test_record.init_total_record: + pass + else: + test_record.record_list.append([function_name, local_param, program_exception]) diff --git a/je_auto_control/utils/test_record/record_test_result_class.py b/je_auto_control/utils/test_record/record_test_result_class.py deleted file mode 100644 index db170560..00000000 --- a/je_auto_control/utils/test_record/record_test_result_class.py +++ /dev/null @@ -1,13 +0,0 @@ -class TestRecord(object): - - def __init__(self): - self.record_list = list() - self.error_record_list = list() - - def clean_record(self): - self.record_list = list() - self.error_record_list = list() - - -test_record = TestRecord() - diff --git a/je_auto_control/wrapper/auto_control_image.py b/je_auto_control/wrapper/auto_control_image.py index b998f2ae..2ff3a8fd 100644 --- a/je_auto_control/wrapper/auto_control_image.py +++ b/je_auto_control/wrapper/auto_control_image.py @@ -1,3 +1,5 @@ +import sys + from je_auto_control.utils.image import template_detection from je_auto_control.utils.exception.exception_tag import cant_find_image from je_auto_control.utils.exception.exception_tag import find_image_error_variable @@ -5,6 +7,7 @@ from je_auto_control.wrapper.auto_control_mouse import click_mouse from je_auto_control.wrapper.auto_control_mouse import set_position from je_auto_control.utils.image.screenshot import pil_screenshot +from je_auto_control.utils.test_record.record_test_class import record_total def locate_all_image(image, detect_threshold: [float, int] = 1, draw_image: bool = False): @@ -14,14 +17,20 @@ def locate_all_image(image, detect_threshold: [float, int] = 1, draw_image: bool :param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal (float or int) :param draw_image draw detect tag on return image (bool) """ + param = locals() try: - image_data_array = template_detection.find_image_multi(image, detect_threshold, draw_image) - except ImageNotFoundException: - raise ImageNotFoundException(find_image_error_variable) - if image_data_array[0] is True: - return image_data_array[1] - else: - raise ImageNotFoundException(cant_find_image) + try: + image_data_array = template_detection.find_image_multi(image, detect_threshold, draw_image) + except ImageNotFoundException: + raise ImageNotFoundException(find_image_error_variable) + if image_data_array[0] is True: + record_total("locate_all_image", param) + return image_data_array[1] + else: + raise ImageNotFoundException(cant_find_image) + except Exception as error: + record_total("locate_all_image", param, repr(error)) + print(repr(error), file=sys.stderr) def locate_image_center(image, detect_threshold: [float, int] = 1, draw_image: bool = False): @@ -31,17 +40,23 @@ def locate_image_center(image, detect_threshold: [float, int] = 1, draw_image: b :param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal (float or int) :param draw_image draw detect tag on return image (bool) """ + param = locals() try: - image_data_array = template_detection.find_image(image, detect_threshold, draw_image) - except ImageNotFoundException: - raise ImageNotFoundException(find_image_error_variable) - if image_data_array[0] is True: - height = image_data_array[1][2] - image_data_array[1][0] - width = image_data_array[1][3] - image_data_array[1][1] - center = [int(height / 2), int(width / 2)] - return [image_data_array[1][0] + center[0], image_data_array[1][1] + center[1]] - else: - raise ImageNotFoundException(cant_find_image) + try: + image_data_array = template_detection.find_image(image, detect_threshold, draw_image) + except ImageNotFoundException: + raise ImageNotFoundException(find_image_error_variable) + if image_data_array[0] is True: + height = image_data_array[1][2] - image_data_array[1][0] + width = image_data_array[1][3] - image_data_array[1][1] + center = [int(height / 2), int(width / 2)] + record_total("locate_image_center", param) + return [image_data_array[1][0] + center[0], image_data_array[1][1] + center[1]] + else: + raise ImageNotFoundException(cant_find_image) + except Exception as error: + record_total("locate_image_center", param, repr(error)) + print(repr(error), file=sys.stderr) def locate_and_click(image, mouse_keycode: [int, str], detect_threshold: [float, int] = 1, draw_image: bool = False): @@ -52,21 +67,27 @@ def locate_and_click(image, mouse_keycode: [int, str], detect_threshold: [float, :param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal (float or int) :param draw_image draw detect tag on return image (bool) """ + param = locals() try: - image_data_array = template_detection.find_image(image, detect_threshold, draw_image) - except ImageNotFoundException: - raise ImageNotFoundException(find_image_error_variable) - if image_data_array[0] is True: - height = image_data_array[1][2] - image_data_array[1][0] - width = image_data_array[1][3] - image_data_array[1][1] - center = [int(height / 2), int(width / 2)] - image_center_x = image_data_array[1][0] + center[0] - image_center_y = image_data_array[1][1] + center[1] - set_position(int(image_center_x), int(image_center_y)) - click_mouse(mouse_keycode) - return [image_center_x, image_center_y] - else: - raise ImageNotFoundException(cant_find_image) + try: + image_data_array = template_detection.find_image(image, detect_threshold, draw_image) + except ImageNotFoundException: + raise ImageNotFoundException(find_image_error_variable) + if image_data_array[0] is True: + height = image_data_array[1][2] - image_data_array[1][0] + width = image_data_array[1][3] - image_data_array[1][1] + center = [int(height / 2), int(width / 2)] + image_center_x = image_data_array[1][0] + center[0] + image_center_y = image_data_array[1][1] + center[1] + set_position(int(image_center_x), int(image_center_y)) + click_mouse(mouse_keycode) + record_total("locate_and_click", param) + return [image_center_x, image_center_y] + else: + raise ImageNotFoundException(cant_find_image) + except Exception as error: + record_total("locate_and_click", param, repr(error)) + print(repr(error), file=sys.stderr) def screenshot(file_path: str = None, region: list = None): @@ -75,4 +96,10 @@ def screenshot(file_path: str = None, region: list = None): :param file_path save screenshot path (None is no save) :param region screenshot region (screenshot region on screen) """ - return pil_screenshot(file_path, region) + param = locals() + try: + record_total("screenshot", param) + return pil_screenshot(file_path, region) + except Exception as error: + print(repr(error), file=sys.stderr) + record_total("screenshot", param, repr(error)) diff --git a/je_auto_control/wrapper/auto_control_keyboard.py b/je_auto_control/wrapper/auto_control_keyboard.py index 886b0664..83004bb3 100644 --- a/je_auto_control/wrapper/auto_control_keyboard.py +++ b/je_auto_control/wrapper/auto_control_keyboard.py @@ -12,6 +12,7 @@ from je_auto_control.wrapper.platform_wrapper import keyboard from je_auto_control.wrapper.platform_wrapper import keyboard_check from je_auto_control.wrapper.platform_wrapper import keys_table +from je_auto_control.utils.test_record.record_test_class import record_total def press_key(keycode: [int, str], is_shift: bool = False): @@ -22,21 +23,27 @@ def press_key(keycode: [int, str], is_shift: bool = False): :param keycode which keycode we want to press :param is_shift press shift True or False """ - if type(keycode) is not int: - try: - keycode = keys_table.get(keycode) - except AutoControlCantFindKeyException: - raise AutoControlCantFindKeyException(table_cant_find_key) + param = locals() try: - if sys.platform in ["win32", "cygwin", "msys", "linux", "linux2"]: - keyboard.press_key(keycode) - elif sys.platform in ["darwin"]: - keyboard.press_key(keycode, is_shift=is_shift) - return str(keycode) - except AutoControlKeyboardException: - raise AutoControlKeyboardException(keyboard_press_key) - except TypeError as error: - raise AutoControlKeyboardException(repr(error)) + if type(keycode) is not int: + try: + keycode = keys_table.get(keycode) + except AutoControlCantFindKeyException: + raise AutoControlCantFindKeyException(table_cant_find_key) + try: + if sys.platform in ["win32", "cygwin", "msys", "linux", "linux2"]: + keyboard.press_key(keycode) + elif sys.platform in ["darwin"]: + keyboard.press_key(keycode, is_shift=is_shift) + record_total("press_key", param) + return str(keycode) + except AutoControlKeyboardException: + raise AutoControlKeyboardException(keyboard_press_key) + except TypeError as error: + raise AutoControlKeyboardException(repr(error)) + except Exception as error: + record_total("press_key", param, repr(error)) + print(repr(error), file=sys.stderr) def release_key(keycode: [int, str], is_shift: bool = False): @@ -45,21 +52,27 @@ def release_key(keycode: [int, str], is_shift: bool = False): :param keycode which keycode we want to release :param is_shift press shift True or False """ - if type(keycode) is not int: - try: - keycode = keys_table.get(keycode) - except AutoControlCantFindKeyException: - raise AutoControlCantFindKeyException(table_cant_find_key) + param = locals() try: - if sys.platform in ["win32", "cygwin", "msys", "linux", "linux2"]: - keyboard.release_key(keycode) - elif sys.platform in ["darwin"]: - keyboard.release_key(keycode, is_shift=is_shift) - return str(keycode) - except AutoControlKeyboardException: - raise AutoControlKeyboardException(keyboard_release_key) - except TypeError as error: - raise AutoControlKeyboardException(repr(error)) + if type(keycode) is not int: + try: + keycode = keys_table.get(keycode) + except AutoControlCantFindKeyException: + raise AutoControlCantFindKeyException(table_cant_find_key) + try: + if sys.platform in ["win32", "cygwin", "msys", "linux", "linux2"]: + keyboard.release_key(keycode) + elif sys.platform in ["darwin"]: + keyboard.release_key(keycode, is_shift=is_shift) + record_total("release_key", param) + return str(keycode) + except AutoControlKeyboardException: + raise AutoControlKeyboardException(keyboard_release_key) + except TypeError as error: + raise AutoControlKeyboardException(repr(error)) + except Exception as error: + record_total("release_key", param, repr(error)) + print(repr(error), file=sys.stderr) def type_key(keycode: [int, str], is_shift: bool = False): @@ -68,14 +81,20 @@ def type_key(keycode: [int, str], is_shift: bool = False): :param keycode which keycode we want to type :param is_shift press shift True or False """ + param = locals() try: - press_key(keycode, is_shift) - release_key(keycode, is_shift) - return str(keycode) - except AutoControlKeyboardException: - raise AutoControlKeyboardException(keyboard_type_key) - except TypeError as error: - raise AutoControlKeyboardException(repr(error)) + try: + press_key(keycode, is_shift) + release_key(keycode, is_shift) + record_total("type_key", param) + return str(keycode) + except AutoControlKeyboardException: + raise AutoControlKeyboardException(keyboard_type_key) + except TypeError as error: + raise AutoControlKeyboardException(repr(error)) + except Exception as error: + record_total("type_key", param, repr(error)) + print(repr(error), file=sys.stderr) def check_key_is_press(keycode: [int, str]): @@ -83,11 +102,17 @@ def check_key_is_press(keycode: [int, str]): use to check key is press return True or False :param keycode check key is press or not """ - if type(keycode) is int: - get_key_code = keycode - else: - get_key_code = keys_table.get(keycode) - return keyboard_check.check_key_is_press(keycode=get_key_code) + param = locals() + try: + if type(keycode) is int: + get_key_code = keycode + else: + get_key_code = keys_table.get(keycode) + record_total("check_key_is_press", param) + return keyboard_check.check_key_is_press(keycode=get_key_code) + except Exception as error: + record_total("check_key_is_press", param, repr(error)) + print(repr(error), file=sys.stderr) def write(write_string: str, is_shift: bool = False): @@ -97,20 +122,26 @@ def write(write_string: str, is_shift: bool = False): :param write_string while string not on write_string+1 type_key(string) :param is_shift press shift True or False """ + param = locals() try: - record_write_string = "" - for single_string in write_string: - try: - if keys_table.get(single_string) is not None: - record_write_string = "".join([record_write_string, type_key(single_string, is_shift)]) - else: + try: + record_write_string = "" + for single_string in write_string: + try: + if keys_table.get(single_string) is not None: + record_write_string = "".join([record_write_string, type_key(single_string, is_shift)]) + else: + raise AutoControlKeyboardException(keyboard_write_cant_find) + except AutoControlKeyboardException: + print(keyboard_write_cant_find, single_string, sep="\t", file=sys.stderr) raise AutoControlKeyboardException(keyboard_write_cant_find) - except AutoControlKeyboardException: - print(keyboard_write_cant_find, single_string, sep="\t", file=sys.stderr) - raise AutoControlKeyboardException(keyboard_write_cant_find) - return record_write_string - except AutoControlKeyboardException: - raise AutoControlKeyboardException(keyboard_write) + record_total("write", param) + return record_write_string + except AutoControlKeyboardException: + raise AutoControlKeyboardException(keyboard_write) + except Exception as error: + record_total("write", param, repr(error)) + print(repr(error), file=sys.stderr) def hotkey(key_code_list: list, is_shift: bool = False): @@ -121,14 +152,20 @@ def hotkey(key_code_list: list, is_shift: bool = False): :param key_code_list press and release all key on list and reverse :param is_shift press shift True or False """ + param = locals() try: - record_hotkey_press_string = "" - record_hotkey_release_string = "" - for key in key_code_list: - record_hotkey_press_string = ",".join([record_hotkey_press_string, press_key(key, is_shift)]) - key_code_list.reverse() - for key in key_code_list: - record_hotkey_release_string = ",".join([record_hotkey_release_string, release_key(key, is_shift)]) - return record_hotkey_press_string, record_hotkey_release_string - except AutoControlKeyboardException: - raise AutoControlKeyboardException(keyboard_hotkey) + try: + record_hotkey_press_string = "" + record_hotkey_release_string = "" + for key in key_code_list: + record_hotkey_press_string = ",".join([record_hotkey_press_string, press_key(key, is_shift)]) + key_code_list.reverse() + for key in key_code_list: + record_hotkey_release_string = ",".join([record_hotkey_release_string, release_key(key, is_shift)]) + record_total("hotkey", param) + return record_hotkey_press_string, record_hotkey_release_string + except AutoControlKeyboardException: + raise AutoControlKeyboardException(keyboard_hotkey) + except Exception as error: + record_total("hotkey", param, repr(error)) + print(repr(error), file=sys.stderr) diff --git a/je_auto_control/wrapper/auto_control_mouse.py b/je_auto_control/wrapper/auto_control_mouse.py index 26c69a7b..37bd9c46 100644 --- a/je_auto_control/wrapper/auto_control_mouse.py +++ b/je_auto_control/wrapper/auto_control_mouse.py @@ -15,6 +15,7 @@ from je_auto_control.wrapper.platform_wrapper import mouse from je_auto_control.wrapper.platform_wrapper import mouse_table from je_auto_control.wrapper.platform_wrapper import special_table +from je_auto_control.utils.test_record.record_test_class import record_total def mouse_preprocess(mouse_keycode: [int, str], x: int, y: int): @@ -50,9 +51,14 @@ def position(): return mouse_x, mouse_y """ try: - return mouse.position() - except AutoControlMouseException: - raise AutoControlMouseException(mouse_get_position) + try: + record_total("position", None) + return mouse.position() + except AutoControlMouseException: + raise AutoControlMouseException(mouse_get_position) + except Exception as error: + record_total("position", None, repr(error)) + print(repr(error), file=sys.stderr) def set_position(x: int, y: int): @@ -61,13 +67,19 @@ def set_position(x: int, y: int): :param y set mouse position y return x, y """ + param = locals() try: - mouse.set_position(x=x, y=y) - return x, y - except AutoControlMouseException: - raise AutoControlMouseException(mouse_set_position) - except ctypes.ArgumentError: - raise AutoControlMouseException(mouse_wrong_value) + try: + mouse.set_position(x=x, y=y) + record_total("position", param) + return x, y + except AutoControlMouseException: + raise AutoControlMouseException(mouse_set_position) + except ctypes.ArgumentError: + raise AutoControlMouseException(mouse_wrong_value) + except Exception as error: + record_total("set_position", param, repr(error)) + print(repr(error), file=sys.stderr) def press_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): @@ -78,17 +90,23 @@ def press_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): :param x mouse click x position :param y mouse click y position """ - mouse_keycode, x, y = mouse_preprocess(mouse_keycode, x, y) + param = locals() try: - if sys.platform in ["win32", "cygwin", "msys", "linux", "linux2"]: - mouse.press_mouse(mouse_keycode) - elif sys.platform in ["darwin"]: - mouse.press_mouse(x, y, mouse_keycode) - return mouse_keycode, x, y - except AutoControlMouseException: - raise AutoControlMouseException(mouse_press_mouse) - except TypeError as error: - raise AutoControlMouseException(repr(error)) + mouse_keycode, x, y = mouse_preprocess(mouse_keycode, x, y) + try: + if sys.platform in ["win32", "cygwin", "msys", "linux", "linux2"]: + mouse.press_mouse(mouse_keycode) + elif sys.platform in ["darwin"]: + mouse.press_mouse(x, y, mouse_keycode) + record_total("press_mouse", param) + return mouse_keycode, x, y + except AutoControlMouseException: + raise AutoControlMouseException(mouse_press_mouse) + except TypeError as error: + raise AutoControlMouseException(repr(error)) + except Exception as error: + record_total("press_mouse", param, repr(error)) + print(repr(error), file=sys.stderr) def release_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): @@ -99,17 +117,23 @@ def release_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): :param x mouse click x position :param y mouse click y position """ - mouse_keycode, x, y = mouse_preprocess(mouse_keycode, x, y) + param = locals() try: - if sys.platform in ["win32", "cygwin", "msys", "linux", "linux2"]: - mouse.release_mouse(mouse_keycode) - elif sys.platform in ["darwin"]: - mouse.release_mouse(x, y, mouse_keycode) - return mouse_keycode, x, y - except AutoControlMouseException: - raise AutoControlMouseException(mouse_release_mouse) - except TypeError as error: - raise AutoControlMouseException(repr(error)) + mouse_keycode, x, y = mouse_preprocess(mouse_keycode, x, y) + try: + if sys.platform in ["win32", "cygwin", "msys", "linux", "linux2"]: + mouse.release_mouse(mouse_keycode) + elif sys.platform in ["darwin"]: + mouse.release_mouse(x, y, mouse_keycode) + record_total("press_mouse", param) + return mouse_keycode, x, y + except AutoControlMouseException: + raise AutoControlMouseException(mouse_release_mouse) + except TypeError as error: + raise AutoControlMouseException(repr(error)) + except Exception as error: + record_total("release_mouse", param, repr(error)) + print(repr(error), file=sys.stderr) def click_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): @@ -120,14 +144,20 @@ def click_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): :param x mouse click x position :param y mouse click y position """ - mouse_keycode, x, y = mouse_preprocess(mouse_keycode, x, y) + param = locals() try: - mouse.click_mouse(mouse_keycode, x, y) - return mouse_keycode, x, y - except AutoControlMouseException: - raise AutoControlMouseException(mouse_click_mouse) - except TypeError as error: - raise AutoControlMouseException(repr(error)) + mouse_keycode, x, y = mouse_preprocess(mouse_keycode, x, y) + try: + mouse.click_mouse(mouse_keycode, x, y) + record_total("click_mouse", param) + return mouse_keycode, x, y + except AutoControlMouseException: + raise AutoControlMouseException(mouse_click_mouse) + except TypeError as error: + raise AutoControlMouseException(repr(error)) + except Exception as error: + record_total("click_mouse", param, repr(error)) + print(repr(error), file=sys.stderr) def scroll(scroll_value: int, x: int = None, y: int = None, scroll_direction: str = "scroll_down"): @@ -141,35 +171,41 @@ def scroll(scroll_value: int, x: int = None, y: int = None, scroll_direction: st scroll_direction = scroll_left : direction left scroll_direction = scroll_right : direction right """ + param = locals() try: - now_cursor_x, now_cursor_y = position() - except AutoControlMouseException: - raise AutoControlMouseException(mouse_get_position) - width, height = size() - if x is None: - x = now_cursor_x - else: - if x < 0: - x = 0 - elif x >= width: - x = width - 1 - if y is None: - y = now_cursor_y - else: - if y < 0: - y = 0 - elif y >= height: - y = height - 1 - try: - if sys.platform in ["win32", "cygwin", "msys"]: - mouse.scroll(scroll_value, x, y) - elif sys.platform in ["darwin"]: - mouse.scroll(scroll_value) - elif sys.platform in ["linux", "linux2"]: - scroll_direction = special_table.get(scroll_direction) - mouse.scroll(scroll_value, scroll_direction) - return scroll_value, scroll_direction - except AutoControlMouseException: - raise AutoControlMouseException(mouse_scroll) - except TypeError as error: - raise AutoControlMouseException(repr(error)) + try: + now_cursor_x, now_cursor_y = position() + except AutoControlMouseException: + raise AutoControlMouseException(mouse_get_position) + width, height = size() + if x is None: + x = now_cursor_x + else: + if x < 0: + x = 0 + elif x >= width: + x = width - 1 + if y is None: + y = now_cursor_y + else: + if y < 0: + y = 0 + elif y >= height: + y = height - 1 + try: + if sys.platform in ["win32", "cygwin", "msys"]: + mouse.scroll(scroll_value, x, y) + elif sys.platform in ["darwin"]: + mouse.scroll(scroll_value) + elif sys.platform in ["linux", "linux2"]: + scroll_direction = special_table.get(scroll_direction) + mouse.scroll(scroll_value, scroll_direction) + record_total("scroll", param) + return scroll_value, scroll_direction + except AutoControlMouseException: + raise AutoControlMouseException(mouse_scroll) + except TypeError as error: + raise AutoControlMouseException(repr(error)) + except Exception as error: + record_total("scroll", param, repr(error)) + print(repr(error), file=sys.stderr) diff --git a/je_auto_control/wrapper/auto_control_record.py b/je_auto_control/wrapper/auto_control_record.py index 5cd992d2..69596171 100644 --- a/je_auto_control/wrapper/auto_control_record.py +++ b/je_auto_control/wrapper/auto_control_record.py @@ -5,32 +5,43 @@ from je_auto_control.utils.exception.exceptions import AutoControlException from je_auto_control.utils.exception.exceptions import AutoControlJsonActionException from je_auto_control.wrapper.platform_wrapper import recorder +from je_auto_control.utils.test_record.record_test_class import record_total def record(): """ start record keyboard and mouse event until stop_record """ - if sys.platform == "darwin": - raise AutoControlException(macos_record_error) - return recorder.record() + try: + if sys.platform == "darwin": + raise AutoControlException(macos_record_error) + record_total("record", None) + return recorder.record() + except Exception as error: + record_total("record", None, repr(error)) + print(repr(error), file=sys.stderr) def stop_record(): """ stop current record """ - if sys.platform == "darwin": - raise AutoControlException(macos_record_error) - action_queue = recorder.stop_record() - if action_queue is None: - raise AutoControlJsonActionException - action_list = list(action_queue.queue) - new_list = list() - for action in action_list: - if action[0] == "type_key": - new_list.append([action[0], dict([["keycode", action[1]]])]) - else: - new_list.append([action[0], dict(zip(["mouse_keycode", "x", "y"], [action[0], action[1], action[2]]))]) - return new_list + try: + if sys.platform == "darwin": + raise AutoControlException(macos_record_error) + action_queue = recorder.stop_record() + if action_queue is None: + raise AutoControlJsonActionException + action_list = list(action_queue.queue) + new_list = list() + for action in action_list: + if action[0] == "type_key": + new_list.append([action[0], dict([["keycode", action[1]]])]) + else: + new_list.append([action[0], dict(zip(["mouse_keycode", "x", "y"], [action[0], action[1], action[2]]))]) + record_total("stop_record", None) + return new_list + except Exception as error: + record_total("stop_record", None, repr(error)) + print(repr(error), file=sys.stderr) diff --git a/je_auto_control/wrapper/auto_control_screen.py b/je_auto_control/wrapper/auto_control_screen.py index 5712d383..8bf75e79 100644 --- a/je_auto_control/wrapper/auto_control_screen.py +++ b/je_auto_control/wrapper/auto_control_screen.py @@ -1,3 +1,5 @@ +import sys + import cv2 import numpy as np @@ -6,6 +8,7 @@ from je_auto_control.utils.exception.exception_tag import screen_screenshot from je_auto_control.utils.exception.exceptions import AutoControlScreenException from je_auto_control.wrapper.platform_wrapper import screen +from je_auto_control.utils.test_record.record_test_class import record_total def size(): @@ -13,9 +16,14 @@ def size(): get screen size """ try: - return screen.size() - except AutoControlScreenException: - raise AutoControlScreenException(screen_get_size) + try: + record_total("size", None) + return screen.size() + except AutoControlScreenException: + raise AutoControlScreenException(screen_get_size) + except Exception as error: + record_total("size", None, repr(error)) + print(repr(error), file=sys.stderr) def screenshot(file_path: str = None, region: list = None): @@ -24,7 +32,13 @@ def screenshot(file_path: str = None, region: list = None): :param file_path screenshot file save path :param region screenshot region """ + param = locals() try: - return cv2.cvtColor(np.array(pil_screenshot(file_path=file_path, region=region)), cv2.COLOR_RGB2BGR) - except AutoControlScreenException: - raise AutoControlScreenException(screen_screenshot) + try: + record_total("screenshot", param) + return cv2.cvtColor(np.array(pil_screenshot(file_path=file_path, region=region)), cv2.COLOR_RGB2BGR) + except AutoControlScreenException: + raise AutoControlScreenException(screen_screenshot) + except Exception as error: + record_total("screenshot", None, repr(error)) + print(repr(error), file=sys.stderr) From cf89ea324ba78ef34db6b72f4d1f407ea8649023 Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Sun, 27 Mar 2022 00:33:19 +0800 Subject: [PATCH 03/15] fix test error fix test error --- test/unit_test/keyboard/keyboard_write_test.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/unit_test/keyboard/keyboard_write_test.py b/test/unit_test/keyboard/keyboard_write_test.py index 570de8bf..38c66ed9 100644 --- a/test/unit_test/keyboard/keyboard_write_test.py +++ b/test/unit_test/keyboard/keyboard_write_test.py @@ -25,10 +25,9 @@ """ try: assert (write("Ѓ123456789") == "123456789") -except AutoControlKeyboardException as error: +except Exception as error: print(repr(error), file=sys.stderr) try: write("!#@L@#{@#PL#{!@#L{!#{|##PO}!@#O@!O#P!)KI#O_!K") -except AutoControlKeyboardException as error: +except Exception as error: print(repr(error), file=sys.stderr) - From 35a689137d1a05f6cc97d22bdac7469de798cfab Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Sun, 27 Mar 2022 12:41:50 +0800 Subject: [PATCH 04/15] update dev version refactor exception --- .idea/workspace.xml | 64 +++++++++++++++++-- dev_setup.py | 2 +- .../utils/test_record/record_test_class.py | 2 +- je_auto_control/wrapper/auto_control_image.py | 8 +-- .../wrapper/auto_control_keyboard.py | 20 +++--- je_auto_control/wrapper/auto_control_mouse.py | 32 +++++----- .../wrapper/auto_control_screen.py | 4 +- .../unit_test/keyboard/keyboard_write_test.py | 3 +- .../total_record_test/total_record_test.py | 36 +++++++++++ 9 files changed, 128 insertions(+), 43 deletions(-) create mode 100644 test/unit_test/total_record_test/total_record_test.py diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c7c05311..61cac738 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,15 +2,15 @@ + - - - + + - + - + + + + + + + @@ -372,6 +421,7 @@ + @@ -388,7 +438,7 @@ - + diff --git a/dev_setup.py b/dev_setup.py index 1af24a01..b303c9ae 100644 --- a/dev_setup.py +++ b/dev_setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="je_auto_control_dev", - version="0.0.09", + version="0.0.10", author="JE-Chen", author_email="zenmailman@gmail.com", description="auto testing", diff --git a/je_auto_control/utils/test_record/record_test_class.py b/je_auto_control/utils/test_record/record_test_class.py index e9c1fb0c..3b04aecf 100644 --- a/je_auto_control/utils/test_record/record_test_class.py +++ b/je_auto_control/utils/test_record/record_test_class.py @@ -19,4 +19,4 @@ def record_total(function_name: str, local_param, program_exception: str = None) if not test_record.init_total_record: pass else: - test_record.record_list.append([function_name, local_param, program_exception]) + test_record.total_record_list.append([function_name, local_param, program_exception]) diff --git a/je_auto_control/wrapper/auto_control_image.py b/je_auto_control/wrapper/auto_control_image.py index 2ff3a8fd..2a8c73a9 100644 --- a/je_auto_control/wrapper/auto_control_image.py +++ b/je_auto_control/wrapper/auto_control_image.py @@ -21,8 +21,8 @@ def locate_all_image(image, detect_threshold: [float, int] = 1, draw_image: bool try: try: image_data_array = template_detection.find_image_multi(image, detect_threshold, draw_image) - except ImageNotFoundException: - raise ImageNotFoundException(find_image_error_variable) + except ImageNotFoundException as error: + raise ImageNotFoundException(find_image_error_variable + repr(error)) if image_data_array[0] is True: record_total("locate_all_image", param) return image_data_array[1] @@ -44,8 +44,8 @@ def locate_image_center(image, detect_threshold: [float, int] = 1, draw_image: b try: try: image_data_array = template_detection.find_image(image, detect_threshold, draw_image) - except ImageNotFoundException: - raise ImageNotFoundException(find_image_error_variable) + except ImageNotFoundException as error: + raise ImageNotFoundException(find_image_error_variable + repr(error)) if image_data_array[0] is True: height = image_data_array[1][2] - image_data_array[1][0] width = image_data_array[1][3] - image_data_array[1][1] diff --git a/je_auto_control/wrapper/auto_control_keyboard.py b/je_auto_control/wrapper/auto_control_keyboard.py index 83004bb3..4442dd39 100644 --- a/je_auto_control/wrapper/auto_control_keyboard.py +++ b/je_auto_control/wrapper/auto_control_keyboard.py @@ -37,8 +37,8 @@ def press_key(keycode: [int, str], is_shift: bool = False): keyboard.press_key(keycode, is_shift=is_shift) record_total("press_key", param) return str(keycode) - except AutoControlKeyboardException: - raise AutoControlKeyboardException(keyboard_press_key) + except AutoControlKeyboardException as error: + raise AutoControlKeyboardException(keyboard_press_key + repr(error)) except TypeError as error: raise AutoControlKeyboardException(repr(error)) except Exception as error: @@ -66,8 +66,8 @@ def release_key(keycode: [int, str], is_shift: bool = False): keyboard.release_key(keycode, is_shift=is_shift) record_total("release_key", param) return str(keycode) - except AutoControlKeyboardException: - raise AutoControlKeyboardException(keyboard_release_key) + except AutoControlKeyboardException as error: + raise AutoControlKeyboardException(keyboard_release_key + repr(error)) except TypeError as error: raise AutoControlKeyboardException(repr(error)) except Exception as error: @@ -88,8 +88,8 @@ def type_key(keycode: [int, str], is_shift: bool = False): release_key(keycode, is_shift) record_total("type_key", param) return str(keycode) - except AutoControlKeyboardException: - raise AutoControlKeyboardException(keyboard_type_key) + except AutoControlKeyboardException as error: + raise AutoControlKeyboardException(keyboard_type_key + repr(error)) except TypeError as error: raise AutoControlKeyboardException(repr(error)) except Exception as error: @@ -137,8 +137,8 @@ def write(write_string: str, is_shift: bool = False): raise AutoControlKeyboardException(keyboard_write_cant_find) record_total("write", param) return record_write_string - except AutoControlKeyboardException: - raise AutoControlKeyboardException(keyboard_write) + except AutoControlKeyboardException as error: + raise AutoControlKeyboardException(keyboard_write + repr(error)) except Exception as error: record_total("write", param, repr(error)) print(repr(error), file=sys.stderr) @@ -164,8 +164,8 @@ def hotkey(key_code_list: list, is_shift: bool = False): record_hotkey_release_string = ",".join([record_hotkey_release_string, release_key(key, is_shift)]) record_total("hotkey", param) return record_hotkey_press_string, record_hotkey_release_string - except AutoControlKeyboardException: - raise AutoControlKeyboardException(keyboard_hotkey) + except AutoControlKeyboardException as error: + raise AutoControlKeyboardException(keyboard_hotkey + repr(error)) except Exception as error: record_total("hotkey", param, repr(error)) print(repr(error), file=sys.stderr) diff --git a/je_auto_control/wrapper/auto_control_mouse.py b/je_auto_control/wrapper/auto_control_mouse.py index 37bd9c46..9f0acbf8 100644 --- a/je_auto_control/wrapper/auto_control_mouse.py +++ b/je_auto_control/wrapper/auto_control_mouse.py @@ -40,8 +40,8 @@ def mouse_preprocess(mouse_keycode: [int, str], x: int, y: int): x = now_x if y is None: y = now_y - except AutoControlMouseException: - raise AutoControlMouseException(mouse_get_position) + except AutoControlMouseException as error: + raise AutoControlMouseException(mouse_get_position + repr(error)) return mouse_keycode, x, y @@ -54,8 +54,8 @@ def position(): try: record_total("position", None) return mouse.position() - except AutoControlMouseException: - raise AutoControlMouseException(mouse_get_position) + except AutoControlMouseException as error: + raise AutoControlMouseException(mouse_get_position + repr(error)) except Exception as error: record_total("position", None, repr(error)) print(repr(error), file=sys.stderr) @@ -73,10 +73,10 @@ def set_position(x: int, y: int): mouse.set_position(x=x, y=y) record_total("position", param) return x, y - except AutoControlMouseException: - raise AutoControlMouseException(mouse_set_position) - except ctypes.ArgumentError: - raise AutoControlMouseException(mouse_wrong_value) + except AutoControlMouseException as error: + raise AutoControlMouseException(mouse_set_position + repr(error)) + except ctypes.ArgumentError as error: + raise AutoControlMouseException(mouse_wrong_value + repr(error)) except Exception as error: record_total("set_position", param, repr(error)) print(repr(error), file=sys.stderr) @@ -100,8 +100,8 @@ def press_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): mouse.press_mouse(x, y, mouse_keycode) record_total("press_mouse", param) return mouse_keycode, x, y - except AutoControlMouseException: - raise AutoControlMouseException(mouse_press_mouse) + except AutoControlMouseException as error: + raise AutoControlMouseException(mouse_press_mouse + repr(error)) except TypeError as error: raise AutoControlMouseException(repr(error)) except Exception as error: @@ -127,8 +127,8 @@ def release_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): mouse.release_mouse(x, y, mouse_keycode) record_total("press_mouse", param) return mouse_keycode, x, y - except AutoControlMouseException: - raise AutoControlMouseException(mouse_release_mouse) + except AutoControlMouseException as error: + raise AutoControlMouseException(mouse_release_mouse + repr(error)) except TypeError as error: raise AutoControlMouseException(repr(error)) except Exception as error: @@ -151,8 +151,8 @@ def click_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): mouse.click_mouse(mouse_keycode, x, y) record_total("click_mouse", param) return mouse_keycode, x, y - except AutoControlMouseException: - raise AutoControlMouseException(mouse_click_mouse) + except AutoControlMouseException as error: + raise AutoControlMouseException(mouse_click_mouse + repr(error)) except TypeError as error: raise AutoControlMouseException(repr(error)) except Exception as error: @@ -202,8 +202,8 @@ def scroll(scroll_value: int, x: int = None, y: int = None, scroll_direction: st mouse.scroll(scroll_value, scroll_direction) record_total("scroll", param) return scroll_value, scroll_direction - except AutoControlMouseException: - raise AutoControlMouseException(mouse_scroll) + except AutoControlMouseException as error: + raise AutoControlMouseException(mouse_scroll + repr(error)) except TypeError as error: raise AutoControlMouseException(repr(error)) except Exception as error: diff --git a/je_auto_control/wrapper/auto_control_screen.py b/je_auto_control/wrapper/auto_control_screen.py index 8bf75e79..ad1c1cfa 100644 --- a/je_auto_control/wrapper/auto_control_screen.py +++ b/je_auto_control/wrapper/auto_control_screen.py @@ -37,8 +37,8 @@ def screenshot(file_path: str = None, region: list = None): try: record_total("screenshot", param) return cv2.cvtColor(np.array(pil_screenshot(file_path=file_path, region=region)), cv2.COLOR_RGB2BGR) - except AutoControlScreenException: - raise AutoControlScreenException(screen_screenshot) + except AutoControlScreenException as error: + raise AutoControlScreenException(screen_screenshot + repr(error)) except Exception as error: record_total("screenshot", None, repr(error)) print(repr(error), file=sys.stderr) diff --git a/test/unit_test/keyboard/keyboard_write_test.py b/test/unit_test/keyboard/keyboard_write_test.py index 38c66ed9..5c2e8f72 100644 --- a/test/unit_test/keyboard/keyboard_write_test.py +++ b/test/unit_test/keyboard/keyboard_write_test.py @@ -5,8 +5,6 @@ from je_auto_control import release_key from je_auto_control import write -from je_auto_control import AutoControlKeyboardException - print(keys_table.keys()) press_key("shift") @@ -31,3 +29,4 @@ write("!#@L@#{@#PL#{!@#L{!#{|##PO}!@#O@!O#P!)KI#O_!K") except Exception as error: print(repr(error), file=sys.stderr) + diff --git a/test/unit_test/total_record_test/total_record_test.py b/test/unit_test/total_record_test/total_record_test.py new file mode 100644 index 00000000..706caf49 --- /dev/null +++ b/test/unit_test/total_record_test/total_record_test.py @@ -0,0 +1,36 @@ +import sys + +from je_auto_control import test_record +from je_auto_control import press_key +from je_auto_control import release_key +from je_auto_control import write +from je_auto_control import keys_table + +test_record.init_total_record = True + +print(keys_table.keys()) + +press_key("shift") +write("123456789") +press_key("return") +release_key("return") +assert (write("abcdefghijklmnopqrstuvwxyz") == "abcdefghijklmnopqrstuvwxyz") +release_key("shift") +press_key("return") +release_key("return") +assert (write("abcdefghijklmnopqrstuvwxyz") == "abcdefghijklmnopqrstuvwxyz") +press_key("return") +release_key("return") +""" +this write will print one error -> keyboard write error can't find key : Ѓ and write remain string +""" +try: + assert (write("Ѓ123456789") == "123456789") +except Exception as error: + print(repr(error), file=sys.stderr) +try: + write("!#@L@#{@#PL#{!@#L{!#{|##PO}!@#O@!O#P!)KI#O_!K") +except Exception as error: + print(repr(error), file=sys.stderr) + +print(test_record.total_record_list) From 9dc8999b9fd01ea33b5d1ec612b989a373225298 Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Sun, 27 Mar 2022 23:39:20 +0800 Subject: [PATCH 05/15] update dev version refactor old code add record add html report generate --- .circleci/config.yml | 16 ++ .idea/workspace.xml | 93 ++++++------ dev_setup.py | 2 +- je_auto_control/__init__.py | 3 + .../utils/exception/exception_tag.py | 2 + je_auto_control/utils/exception/exceptions.py | 8 + .../utils/executor/action_executor.py | 56 +++---- je_auto_control/utils/html_report/__init__.py | 0 .../utils/html_report/html_report_generate.py | 140 ++++++++++++++++++ .../utils/test_record/record_test_class.py | 16 +- .../wrapper/auto_control_keyboard.py | 52 +++++-- .../total_record_and_html_report_test.py | 41 +++++ .../execute_action/execute_action_test.py | 4 +- test/unit_test/record/record_test.py | 2 +- 14 files changed, 337 insertions(+), 98 deletions(-) create mode 100644 je_auto_control/utils/html_report/__init__.py create mode 100644 je_auto_control/utils/html_report/html_report_generate.py create mode 100644 test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py diff --git a/.circleci/config.yml b/.circleci/config.yml index 3e1cce0a..9c7d49d2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,6 +63,9 @@ jobs: - run: command: python ./test/unit_test/record/record_test.py name: record_test + - run: + command: python ./test/unit_test/total_record_test/total_record_and_html_report_test.py + name: total_record_test # execute - run: command: python ./test/unit_test/execute_action/execute_action_test.py @@ -91,6 +94,11 @@ jobs: command: python ./test/unit_test/argparse/argparse_test.py name: argparse_test + # integrated_test + - run: + command: python ./test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py + name: total_record_and_html_report_test + build-and-test-windows-stable: executor: name: windows/default @@ -148,6 +156,9 @@ jobs: - run: command: python ./test/unit_test/record/record_test.py name: record_test + - run: + command: python ./test/unit_test/total_record_test/total_record_and_html_report_test.py + name: total_record_test # execute - run: command: python ./test/unit_test/execute_action/execute_action_test.py @@ -176,6 +187,11 @@ jobs: command: python ./test/unit_test/argparse/argparse_test.py name: argparse_test + # integrated_test + - run: + command: python ./test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py + name: total_record_and_html_report_test + workflows: main: jobs: diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 61cac738..42a00da8 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,15 +2,20 @@ - + + + + + + + + - - - - + + + + - - @@ -81,8 +86,8 @@ - - + + - + - + - + - + - + @@ -352,7 +357,8 @@ - + + @@ -387,6 +393,7 @@ + @@ -408,8 +415,8 @@ - - + + @@ -421,7 +428,7 @@ - + @@ -434,6 +441,7 @@ + @@ -445,6 +453,7 @@ + diff --git a/dev_setup.py b/dev_setup.py index b303c9ae..d3074024 100644 --- a/dev_setup.py +++ b/dev_setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="je_auto_control_dev", - version="0.0.10", + version="0.0.11", author="JE-Chen", author_email="zenmailman@gmail.com", description="auto testing", diff --git a/je_auto_control/__init__.py b/je_auto_control/__init__.py index 90fd057f..cb2cd02f 100644 --- a/je_auto_control/__init__.py +++ b/je_auto_control/__init__.py @@ -62,3 +62,6 @@ # utils image from je_auto_control.wrapper.auto_control_image import screenshot +# html report + +from je_auto_control.utils.html_report.html_report_generate import generate_html diff --git a/je_auto_control/utils/exception/exception_tag.py b/je_auto_control/utils/exception/exception_tag.py index e57b55df..b0f1270d 100644 --- a/je_auto_control/utils/exception/exception_tag.py +++ b/je_auto_control/utils/exception/exception_tag.py @@ -44,3 +44,5 @@ action_is_null_error = "json action is null" # timeout tag timeout_need_on_main_error = "should put timeout function on main" +# HTML +html_generate_no_data_tag = "record is None" diff --git a/je_auto_control/utils/exception/exceptions.py b/je_auto_control/utils/exception/exceptions.py index 7db85b99..399c4dfc 100644 --- a/je_auto_control/utils/exception/exceptions.py +++ b/je_auto_control/utils/exception/exceptions.py @@ -60,3 +60,11 @@ class AutoControlActionException(AutoControlException): # timeout class AutoControlTimeoutException(AutoControlException): pass + + +# html exception + +class HTMLException(AutoControlException): + pass + + diff --git a/je_auto_control/utils/executor/action_executor.py b/je_auto_control/utils/executor/action_executor.py index 563a6f2a..6fd2e824 100644 --- a/je_auto_control/utils/executor/action_executor.py +++ b/je_auto_control/utils/executor/action_executor.py @@ -1,5 +1,4 @@ import sys -from je_auto_control import AutoControlActionException from je_auto_control import AutoControlActionNullException from je_auto_control import check_key_is_press from je_auto_control import click_mouse @@ -25,7 +24,7 @@ from je_auto_control.utils.exception.exception_tag import cant_execute_action_error from je_auto_control.utils.exception.exceptions import AutoControlActionException -from je_auto_control.utils.test_record.record_test_class import test_record +from je_auto_control.utils.test_record.record_test_class import record_total event_dict = { # mouse @@ -57,42 +56,33 @@ } -def execute_event(action: list): - event = event_dict.get(action[0]) - if len(action) == 2: - return event(**action[1]) - elif len(action) == 1: - return event() - else: - raise AutoControlActionException(cant_execute_action_error) - - def execute_action(action_list: list): """ use to execute all action on action list(action file or program list) :param action_list the list include action for loop the list and execute action """ - flag = test_record.init_total_record - """ - if init_total_record original is True - make it False and then make it return - """ - if flag: - test_record.init_total_record = False execute_record_string = "" - if action_list is None: - raise AutoControlActionNullException(action_is_null_error) - for action in action_list: - try: - execute_event(action) - temp_string = "execute: " + str(action) - print(temp_string) - test_record.record_list.append(temp_string) - execute_record_string = "".join([execute_record_string, temp_string + "\n"]) - except Exception as error: - print(repr(error), file=sys.stderr) - test_record.error_record_list.append([action, repr(error)]) - if flag: - test_record.init_total_record = True + try: + if action_list is None: + raise AutoControlActionNullException(action_is_null_error) + for action in action_list: + event = event_dict.get(action[0]) + if len(action) == 2: + param = action[1] + event(**action[1]) + elif len(action) == 1: + param = None + event() + else: + raise AutoControlActionException(cant_execute_action_error) + try: + temp_string = "execute: " + str(action) + print(temp_string) + record_total(action[0], param) + execute_record_string = "".join([execute_record_string, temp_string + "\n"]) + except AutoControlActionException as error: + record_total(action[0], param, repr(error)) + except Exception as error: + print(repr(error), file=sys.stderr) return execute_record_string diff --git a/je_auto_control/utils/html_report/__init__.py b/je_auto_control/utils/html_report/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/je_auto_control/utils/html_report/html_report_generate.py b/je_auto_control/utils/html_report/html_report_generate.py new file mode 100644 index 00000000..29b97983 --- /dev/null +++ b/je_auto_control/utils/html_report/html_report_generate.py @@ -0,0 +1,140 @@ +import sys + +from je_auto_control.utils.test_record.record_test_class import test_record +from je_auto_control.utils.exception.exceptions import HTMLException +from je_auto_control.utils.exception.exception_tag import html_generate_no_data_tag +from threading import Lock + +lock = Lock() + +html_string = \ + r""" + + + + + AutoControl Report + + + + +

+ Test Report +

+{event_table} + + +""".strip() + +event_table = \ + r""" + + + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_name{function_name}
param{param}
time{time}
exception{exception}
+
+ """.strip() + + +def generate_html(html_name: str = "default_name"): + """ + :param html_name: save html file name + :return: html_string + """ + if len(test_record.total_record_list) == 0: + raise HTMLException(html_generate_no_data_tag) + else: + event_str = "" + for record_data in test_record.total_record_list: + event_str = "".join( + [ + event_str, + event_table.format( + function_name=record_data.get("function_name"), + param=record_data.get("local_param"), + time=record_data.get("time"), + exception=record_data.get("program_exception"), + ) + ] + ) + new_html_string = html_string.format(event_table=event_str) + try: + lock.acquire() + with open(html_name + ".html", "w+") as file_to_write: + file_to_write.write( + new_html_string + ) + except Exception as error: + print(repr(error), file=sys.stderr) + finally: + lock.release() + return new_html_string diff --git a/je_auto_control/utils/test_record/record_test_class.py b/je_auto_control/utils/test_record/record_test_class.py index 3b04aecf..824a1a81 100644 --- a/je_auto_control/utils/test_record/record_test_class.py +++ b/je_auto_control/utils/test_record/record_test_class.py @@ -1,14 +1,13 @@ +import datetime + + class TestRecord(object): def __init__(self, init_total_record: bool = False): self.init_total_record = init_total_record - self.record_list = list() - self.error_record_list = list() self.total_record_list = list() def clean_record(self): - self.record_list = list() - self.error_record_list = list() self.total_record_list = list() @@ -19,4 +18,11 @@ def record_total(function_name: str, local_param, program_exception: str = None) if not test_record.init_total_record: pass else: - test_record.total_record_list.append([function_name, local_param, program_exception]) + test_record.total_record_list.append( + { + "function_name": function_name, + "local_param": local_param, + "time": str(datetime.datetime.now()), + "program_exception": program_exception + } + ) diff --git a/je_auto_control/wrapper/auto_control_keyboard.py b/je_auto_control/wrapper/auto_control_keyboard.py index 4442dd39..f2733ffa 100644 --- a/je_auto_control/wrapper/auto_control_keyboard.py +++ b/je_auto_control/wrapper/auto_control_keyboard.py @@ -15,13 +15,14 @@ from je_auto_control.utils.test_record.record_test_class import record_total -def press_key(keycode: [int, str], is_shift: bool = False): +def press_key(keycode: [int, str], is_shift: bool = False, skip_record: bool = False): """ use to press a key still press to use release key or use critical exit return keycode :param keycode which keycode we want to press :param is_shift press shift True or False + :param skip_record skip record on record total list True or False """ param = locals() try: @@ -35,22 +36,25 @@ def press_key(keycode: [int, str], is_shift: bool = False): keyboard.press_key(keycode) elif sys.platform in ["darwin"]: keyboard.press_key(keycode, is_shift=is_shift) - record_total("press_key", param) + if not skip_record: + record_total("press_key", param) return str(keycode) except AutoControlKeyboardException as error: raise AutoControlKeyboardException(keyboard_press_key + repr(error)) except TypeError as error: raise AutoControlKeyboardException(repr(error)) except Exception as error: - record_total("press_key", param, repr(error)) + if not skip_record: + record_total("press_key", param, repr(error)) print(repr(error), file=sys.stderr) -def release_key(keycode: [int, str], is_shift: bool = False): +def release_key(keycode: [int, str], is_shift: bool = False, skip_record: bool = False): """ use to release pressed key return keycode :param keycode which keycode we want to release :param is_shift press shift True or False + :param skip_record skip record on record total list True or False """ param = locals() try: @@ -64,36 +68,41 @@ def release_key(keycode: [int, str], is_shift: bool = False): keyboard.release_key(keycode) elif sys.platform in ["darwin"]: keyboard.release_key(keycode, is_shift=is_shift) - record_total("release_key", param) + if not skip_record: + record_total("release_key", param) return str(keycode) except AutoControlKeyboardException as error: raise AutoControlKeyboardException(keyboard_release_key + repr(error)) except TypeError as error: raise AutoControlKeyboardException(repr(error)) except Exception as error: - record_total("release_key", param, repr(error)) + if not skip_record: + record_total("release_key", param, repr(error)) print(repr(error), file=sys.stderr) -def type_key(keycode: [int, str], is_shift: bool = False): +def type_key(keycode: [int, str], is_shift: bool = False, skip_record: bool = False): """ press and release key return keycode :param keycode which keycode we want to type :param is_shift press shift True or False + :param skip_record skip record on record total list True or False """ param = locals() try: try: - press_key(keycode, is_shift) - release_key(keycode, is_shift) - record_total("type_key", param) + press_key(keycode, is_shift, skip_record=True) + release_key(keycode, is_shift, skip_record=True) + if not skip_record: + record_total("type_key", param) return str(keycode) except AutoControlKeyboardException as error: raise AutoControlKeyboardException(keyboard_type_key + repr(error)) except TypeError as error: raise AutoControlKeyboardException(repr(error)) except Exception as error: - record_total("type_key", param, repr(error)) + if not skip_record: + record_total("type_key", param, repr(error)) print(repr(error), file=sys.stderr) @@ -129,7 +138,12 @@ def write(write_string: str, is_shift: bool = False): for single_string in write_string: try: if keys_table.get(single_string) is not None: - record_write_string = "".join([record_write_string, type_key(single_string, is_shift)]) + record_write_string = "".join( + [ + record_write_string, + type_key(single_string, is_shift, skip_record=True) + ] + ) else: raise AutoControlKeyboardException(keyboard_write_cant_find) except AutoControlKeyboardException: @@ -158,10 +172,20 @@ def hotkey(key_code_list: list, is_shift: bool = False): record_hotkey_press_string = "" record_hotkey_release_string = "" for key in key_code_list: - record_hotkey_press_string = ",".join([record_hotkey_press_string, press_key(key, is_shift)]) + record_hotkey_press_string = ",".join( + [ + record_hotkey_press_string, + press_key(key, is_shift, skip_record=True) + ] + ) key_code_list.reverse() for key in key_code_list: - record_hotkey_release_string = ",".join([record_hotkey_release_string, release_key(key, is_shift)]) + record_hotkey_release_string = ",".join( + [ + record_hotkey_release_string, + release_key(key, is_shift, skip_record=True) + ] + ) record_total("hotkey", param) return record_hotkey_press_string, record_hotkey_release_string except AutoControlKeyboardException as error: diff --git a/test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py b/test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py new file mode 100644 index 00000000..94561d95 --- /dev/null +++ b/test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py @@ -0,0 +1,41 @@ +import sys + +from je_auto_control import test_record +from je_auto_control import press_key +from je_auto_control import release_key +from je_auto_control import write +from je_auto_control import keys_table +from je_auto_control import generate_html + +test_record.init_total_record = True + +print(keys_table.keys()) + +press_key("shift") +write("123456789") +press_key("return") +release_key("return") +assert (write("abcdefghijklmnopqrstuvwxyz") == "abcdefghijklmnopqrstuvwxyz") +release_key("shift") +press_key("return") +release_key("return") +assert (write("abcdefghijklmnopqrstuvwxyz") == "abcdefghijklmnopqrstuvwxyz") +press_key("return") +release_key("return") +""" +this write will print one error -> keyboard write error can't find key : Ѓ and write remain string +""" +try: + assert (write("Ѓ123456789") == "123456789") +except Exception as error: + print(repr(error), file=sys.stderr) +try: + write("!#@L@#{@#PL#{!@#L{!#{|##PO}!@#O@!O#P!)KI#O_!K") +except Exception as error: + print(repr(error), file=sys.stderr) + +print(test_record.total_record_list) + +generate_html("test") + + diff --git a/test/unit_test/execute_action/execute_action_test.py b/test/unit_test/execute_action/execute_action_test.py index 140d38a9..59ad7c1f 100644 --- a/test/unit_test/execute_action/execute_action_test.py +++ b/test/unit_test/execute_action/execute_action_test.py @@ -4,6 +4,7 @@ from je_auto_control import test_record test_list = None +test_record.init_total_record = True if sys.platform in ["win32", "cygwin", "msys"]: test_list = [ ["type_key", {"keycode": 65}], @@ -34,5 +35,4 @@ ] print("\n\n") execute_action(test_list) -print(test_record.record_list) -print(test_record.error_record_list) +print(test_record.total_record_list) diff --git a/test/unit_test/record/record_test.py b/test/unit_test/record/record_test.py index 1536e5bb..7da62fdd 100644 --- a/test/unit_test/record/record_test.py +++ b/test/unit_test/record/record_test.py @@ -19,4 +19,4 @@ record_result = stop_record() print(record_result) execute_action(record_result) -sleep(2) +sleep(2) \ No newline at end of file From b1c5e3b572945b9f238b1ded616a23e469700488 Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Sun, 27 Mar 2022 23:52:22 +0800 Subject: [PATCH 06/15] fix ci test wrong path fix ci test wrong path --- .circleci/config.yml | 2 +- .idea/workspace.xml | 14 +------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9c7d49d2..2d9cce8d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -157,7 +157,7 @@ jobs: command: python ./test/unit_test/record/record_test.py name: record_test - run: - command: python ./test/unit_test/total_record_test/total_record_and_html_report_test.py + command: python ./test/unit_test/total_record_test/total_record_test.py name: total_record_test # execute - run: diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 42a00da8..4d1cad1e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,20 +2,7 @@ - - - - - - - - - - - - - From eb2dc96fabb0e5740ed061ddce232329fd50b4ea Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Mon, 28 Mar 2022 00:01:16 +0800 Subject: [PATCH 07/15] fix ci wrong path fix ci wrong path --- .circleci/config.yml | 2 +- .idea/workspace.xml | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2d9cce8d..78cf68ee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,7 +64,7 @@ jobs: command: python ./test/unit_test/record/record_test.py name: record_test - run: - command: python ./test/unit_test/total_record_test/total_record_and_html_report_test.py + command: python ./test/unit_test/total_record_test/total_record_test.py name: total_record_test # execute - run: diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4d1cad1e..9510f381 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,9 +1,7 @@ - - - + From 665ebc397979e07e2d8650c86c0986f653fc61e5 Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Mon, 28 Mar 2022 00:33:01 +0800 Subject: [PATCH 08/15] update dev version update dev version --- .idea/workspace.xml | 14 +++++++++----- dev_setup.py | 2 +- .../utils/test_record/record_test_class.py | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9510f381..de07dd53 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,11 @@ - + + + + + - + @@ -414,7 +418,7 @@ - + diff --git a/dev_setup.py b/dev_setup.py index d3074024..a90dcc8d 100644 --- a/dev_setup.py +++ b/dev_setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="je_auto_control_dev", - version="0.0.11", + version="0.0.12", author="JE-Chen", author_email="zenmailman@gmail.com", description="auto testing", diff --git a/je_auto_control/utils/test_record/record_test_class.py b/je_auto_control/utils/test_record/record_test_class.py index 824a1a81..95b067fd 100644 --- a/je_auto_control/utils/test_record/record_test_class.py +++ b/je_auto_control/utils/test_record/record_test_class.py @@ -23,6 +23,6 @@ def record_total(function_name: str, local_param, program_exception: str = None) "function_name": function_name, "local_param": local_param, "time": str(datetime.datetime.now()), - "program_exception": program_exception + "program_exception": repr(program_exception) } ) From b598d02c8fb0e939238449c13901fe66b0e9360d Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Mon, 28 Mar 2022 00:38:20 +0800 Subject: [PATCH 09/15] fix an test fix an test --- .idea/workspace.xml | 8 +++----- test/unit_test/total_record_test/total_record_test.py | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index de07dd53..c989f977 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,7 @@ - - - + @@ -418,7 +416,7 @@ - + diff --git a/test/unit_test/total_record_test/total_record_test.py b/test/unit_test/total_record_test/total_record_test.py index 706caf49..3c96833f 100644 --- a/test/unit_test/total_record_test/total_record_test.py +++ b/test/unit_test/total_record_test/total_record_test.py @@ -25,7 +25,7 @@ this write will print one error -> keyboard write error can't find key : Ѓ and write remain string """ try: - assert (write("Ѓ123456789") == "123456789") + assert (write("?123456789") == "123456789") except Exception as error: print(repr(error), file=sys.stderr) try: @@ -34,3 +34,4 @@ print(repr(error), file=sys.stderr) print(test_record.total_record_list) + From 474468ba125e3040e18e2c89d0e3b7b02519ad3b Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Mon, 28 Mar 2022 00:42:10 +0800 Subject: [PATCH 10/15] fix an test fix an test --- .../total_record_and_html_report_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py b/test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py index 94561d95..e4572b4b 100644 --- a/test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py +++ b/test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py @@ -26,7 +26,7 @@ this write will print one error -> keyboard write error can't find key : Ѓ and write remain string """ try: - assert (write("Ѓ123456789") == "123456789") + assert (write("?123456789") == "123456789") except Exception as error: print(repr(error), file=sys.stderr) try: From e1e2c74e3226dc48b7b8497e037f65e6fc0c72f2 Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Mon, 28 Mar 2022 09:31:02 +0800 Subject: [PATCH 11/15] update stable vrsion update stable vrsion edit doc --- .circleci/config.yml | 2 +- .idea/workspace.xml | 7 ++++--- docs/source/example/executor_example/execute_action.rst | 3 +-- setup.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 78cf68ee..6f14aa79 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -112,7 +112,7 @@ jobs: name: pip install --upgrade --user pip setuptools wheel # pip require package - run: - command: pip install --user -r dev_requirements.txt + command: pip install --user -r requirements.txt name: pip dev_requirements.txt # screen test - run: diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c989f977..56ffee81 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,8 @@ - + + @@ -416,7 +417,7 @@ - + diff --git a/docs/source/example/executor_example/execute_action.rst b/docs/source/example/executor_example/execute_action.rst index c566169d..b5d5556b 100644 --- a/docs/source/example/executor_example/execute_action.rst +++ b/docs/source/example/executor_example/execute_action.rst @@ -71,8 +71,7 @@ AutoControlGUI Execute action ] print("\n\n") execute_action(test_list) - print(test_record.record_list) - print(test_record.error_record_list) + diff --git a/setup.py b/setup.py index 4092981c..8542805a 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="je_auto_control", - version="0.0.81", + version="0.0.82", author="JE-Chen", author_email="zenmailman@gmail.com", description="auto testing", From 88a2ad4c94721f4d1a2e2fcd07c3103b100f34ae Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Mon, 28 Mar 2022 09:39:30 +0800 Subject: [PATCH 12/15] test --- .circleci/config.yml | 2 +- .idea/workspace.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6f14aa79..abdf767a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 orbs: windows: circleci/windows@2.4.1 - macos: circleci/macos@2.0.1 + mac-permissions: circleci/macos python: circleci/python@1.5.0 jobs: diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 56ffee81..2b63df67 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,6 @@ - From addb14b1191b3c674ffb38ebcb5e173c2c903e74 Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Mon, 28 Mar 2022 09:53:15 +0800 Subject: [PATCH 13/15] refactor exception refactor exception --- .circleci/config.yml | 1 - .idea/workspace.xml | 17 +- .../utils/exception/exception_tag.py | 16 +- je_auto_control/wrapper/auto_control_image.py | 4 +- .../wrapper/auto_control_keyboard.py | 10 +- je_auto_control/wrapper/auto_control_mouse.py | 16 +- .../test.html | 388 ++++++++++++++++++ .../total_record_and_html_report_test.py | 1 - .../total_record_test/total_record_test.py | 1 + 9 files changed, 424 insertions(+), 30 deletions(-) create mode 100644 test/integrated_test/total_record_and_html_report_test/test.html diff --git a/.circleci/config.yml b/.circleci/config.yml index abdf767a..4909108b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,6 @@ version: 2.1 orbs: windows: circleci/windows@2.4.1 - mac-permissions: circleci/macos python: circleci/python@1.5.0 jobs: diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2b63df67..95471576 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,14 @@ + + + + + + + - + @@ -417,7 +424,7 @@ - + @@ -442,7 +449,7 @@ - + diff --git a/je_auto_control/utils/exception/exception_tag.py b/je_auto_control/utils/exception/exception_tag.py index b0f1270d..c3af08d6 100644 --- a/je_auto_control/utils/exception/exception_tag.py +++ b/je_auto_control/utils/exception/exception_tag.py @@ -5,14 +5,14 @@ linux_import_error = "should be only loaded on linux" osx_import_error = "should be only loaded on MacOS" windows_import_error = "should be only loaded on windows" -macos_record_error = "macos can't use recorder" +macos_record_error = "macos cant use recorder" # keyboard tags keyboard_error = "Auto control keyboard error" keyboard_press_key = "keyboard press key error" keyboard_release_key = "keyboard release key error" keyboard_type_key = "keyboard type key error" keyboard_write = "keyboard write error" -keyboard_write_cant_find = "keyboard write error can't find key" +keyboard_write_cant_find = "keyboard write error cant find key" keyboard_hotkey = "keyboard hotkey error" # mouse tags mouse_error = "Auto control mouse error" @@ -28,19 +28,19 @@ screen_get_size = "screen get size error" screen_screenshot = "screen screenshot error" # table tags -table_cant_find_key = "can't find key error" +table_cant_find_key = "cant find key error" # image tags -cant_find_image = "can't find image" +cant_find_image = "cant find image" find_image_error_variable = "variable error" # listener tags listener_error = "Auto control listener error" # test_record tags -record_queue_error = "can't get test_record queue it's none are you using stop test_record before test_record" +record_queue_error = "cant get test_record queue its none are you using stop test_record before test_record" record_not_found_action_error = "test_record action not found" # json action file tag -cant_execute_action_error = "can't execute action" -cant_find_json_error = "can't find json file" -cant_save_json_error = "can't save json file" +cant_execute_action_error = "cant execute action" +cant_find_json_error = "cant find json file" +cant_save_json_error = "cant save json file" action_is_null_error = "json action is null" # timeout tag timeout_need_on_main_error = "should put timeout function on main" diff --git a/je_auto_control/wrapper/auto_control_image.py b/je_auto_control/wrapper/auto_control_image.py index 2a8c73a9..24a3b70d 100644 --- a/je_auto_control/wrapper/auto_control_image.py +++ b/je_auto_control/wrapper/auto_control_image.py @@ -22,7 +22,7 @@ def locate_all_image(image, detect_threshold: [float, int] = 1, draw_image: bool try: image_data_array = template_detection.find_image_multi(image, detect_threshold, draw_image) except ImageNotFoundException as error: - raise ImageNotFoundException(find_image_error_variable + repr(error)) + raise ImageNotFoundException(find_image_error_variable + " " + repr(error)) if image_data_array[0] is True: record_total("locate_all_image", param) return image_data_array[1] @@ -45,7 +45,7 @@ def locate_image_center(image, detect_threshold: [float, int] = 1, draw_image: b try: image_data_array = template_detection.find_image(image, detect_threshold, draw_image) except ImageNotFoundException as error: - raise ImageNotFoundException(find_image_error_variable + repr(error)) + raise ImageNotFoundException(find_image_error_variable + " " + repr(error)) if image_data_array[0] is True: height = image_data_array[1][2] - image_data_array[1][0] width = image_data_array[1][3] - image_data_array[1][1] diff --git a/je_auto_control/wrapper/auto_control_keyboard.py b/je_auto_control/wrapper/auto_control_keyboard.py index f2733ffa..1de732c8 100644 --- a/je_auto_control/wrapper/auto_control_keyboard.py +++ b/je_auto_control/wrapper/auto_control_keyboard.py @@ -40,7 +40,7 @@ def press_key(keycode: [int, str], is_shift: bool = False, skip_record: bool = F record_total("press_key", param) return str(keycode) except AutoControlKeyboardException as error: - raise AutoControlKeyboardException(keyboard_press_key + repr(error)) + raise AutoControlKeyboardException(keyboard_press_key + " " + repr(error)) except TypeError as error: raise AutoControlKeyboardException(repr(error)) except Exception as error: @@ -72,7 +72,7 @@ def release_key(keycode: [int, str], is_shift: bool = False, skip_record: bool = record_total("release_key", param) return str(keycode) except AutoControlKeyboardException as error: - raise AutoControlKeyboardException(keyboard_release_key + repr(error)) + raise AutoControlKeyboardException(keyboard_release_key + " " + repr(error)) except TypeError as error: raise AutoControlKeyboardException(repr(error)) except Exception as error: @@ -97,7 +97,7 @@ def type_key(keycode: [int, str], is_shift: bool = False, skip_record: bool = Fa record_total("type_key", param) return str(keycode) except AutoControlKeyboardException as error: - raise AutoControlKeyboardException(keyboard_type_key + repr(error)) + raise AutoControlKeyboardException(keyboard_type_key + " " + repr(error)) except TypeError as error: raise AutoControlKeyboardException(repr(error)) except Exception as error: @@ -152,7 +152,7 @@ def write(write_string: str, is_shift: bool = False): record_total("write", param) return record_write_string except AutoControlKeyboardException as error: - raise AutoControlKeyboardException(keyboard_write + repr(error)) + raise AutoControlKeyboardException(keyboard_write + " " + repr(error)) except Exception as error: record_total("write", param, repr(error)) print(repr(error), file=sys.stderr) @@ -189,7 +189,7 @@ def hotkey(key_code_list: list, is_shift: bool = False): record_total("hotkey", param) return record_hotkey_press_string, record_hotkey_release_string except AutoControlKeyboardException as error: - raise AutoControlKeyboardException(keyboard_hotkey + repr(error)) + raise AutoControlKeyboardException(keyboard_hotkey + " " + repr(error)) except Exception as error: record_total("hotkey", param, repr(error)) print(repr(error), file=sys.stderr) diff --git a/je_auto_control/wrapper/auto_control_mouse.py b/je_auto_control/wrapper/auto_control_mouse.py index 9f0acbf8..4fb0c9fc 100644 --- a/je_auto_control/wrapper/auto_control_mouse.py +++ b/je_auto_control/wrapper/auto_control_mouse.py @@ -41,7 +41,7 @@ def mouse_preprocess(mouse_keycode: [int, str], x: int, y: int): if y is None: y = now_y except AutoControlMouseException as error: - raise AutoControlMouseException(mouse_get_position + repr(error)) + raise AutoControlMouseException(mouse_get_position + " " + repr(error)) return mouse_keycode, x, y @@ -55,7 +55,7 @@ def position(): record_total("position", None) return mouse.position() except AutoControlMouseException as error: - raise AutoControlMouseException(mouse_get_position + repr(error)) + raise AutoControlMouseException(mouse_get_position + " " + repr(error)) except Exception as error: record_total("position", None, repr(error)) print(repr(error), file=sys.stderr) @@ -74,9 +74,9 @@ def set_position(x: int, y: int): record_total("position", param) return x, y except AutoControlMouseException as error: - raise AutoControlMouseException(mouse_set_position + repr(error)) + raise AutoControlMouseException(mouse_set_position + " " + repr(error)) except ctypes.ArgumentError as error: - raise AutoControlMouseException(mouse_wrong_value + repr(error)) + raise AutoControlMouseException(mouse_wrong_value + " " + repr(error)) except Exception as error: record_total("set_position", param, repr(error)) print(repr(error), file=sys.stderr) @@ -101,7 +101,7 @@ def press_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): record_total("press_mouse", param) return mouse_keycode, x, y except AutoControlMouseException as error: - raise AutoControlMouseException(mouse_press_mouse + repr(error)) + raise AutoControlMouseException(mouse_press_mouse + " " + repr(error)) except TypeError as error: raise AutoControlMouseException(repr(error)) except Exception as error: @@ -128,7 +128,7 @@ def release_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): record_total("press_mouse", param) return mouse_keycode, x, y except AutoControlMouseException as error: - raise AutoControlMouseException(mouse_release_mouse + repr(error)) + raise AutoControlMouseException(mouse_release_mouse + " " + repr(error)) except TypeError as error: raise AutoControlMouseException(repr(error)) except Exception as error: @@ -152,7 +152,7 @@ def click_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): record_total("click_mouse", param) return mouse_keycode, x, y except AutoControlMouseException as error: - raise AutoControlMouseException(mouse_click_mouse + repr(error)) + raise AutoControlMouseException(mouse_click_mouse + " " + repr(error)) except TypeError as error: raise AutoControlMouseException(repr(error)) except Exception as error: @@ -203,7 +203,7 @@ def scroll(scroll_value: int, x: int = None, y: int = None, scroll_direction: st record_total("scroll", param) return scroll_value, scroll_direction except AutoControlMouseException as error: - raise AutoControlMouseException(mouse_scroll + repr(error)) + raise AutoControlMouseException(mouse_scroll + " " + repr(error)) except TypeError as error: raise AutoControlMouseException(repr(error)) except Exception as error: diff --git a/test/integrated_test/total_record_and_html_report_test/test.html b/test/integrated_test/total_record_and_html_report_test/test.html new file mode 100644 index 00000000..7f2c7c9d --- /dev/null +++ b/test/integrated_test/total_record_and_html_report_test/test.html @@ -0,0 +1,388 @@ + + + + + AutoControl Report + + + + +

+ Test Report +

+ + + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_namepress_key
param{'keycode': 'shift', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.464086
exceptionNone
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_namewrite
param{'write_string': '123456789', 'is_shift': False}
time2022-03-28 09:52:29.469092
exceptionNone
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_namepress_key
param{'keycode': 'return', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.469092
exceptionNone
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_namerelease_key
param{'keycode': 'return', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.470093
exceptionNone
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_namewrite
param{'write_string': 'abcdefghijklmnopqrstuvwxyz', 'is_shift': False}
time2022-03-28 09:52:29.483132
exceptionNone
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_namerelease_key
param{'keycode': 'shift', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.483132
exceptionNone
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_namepress_key
param{'keycode': 'return', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.483132
exceptionNone
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_namerelease_key
param{'keycode': 'return', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.483132
exceptionNone
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_namewrite
param{'write_string': 'abcdefghijklmnopqrstuvwxyz', 'is_shift': False}
time2022-03-28 09:52:29.496576
exceptionNone
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_namepress_key
param{'keycode': 'return', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.496576
exceptionNone
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_namerelease_key
param{'keycode': 'return', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.496576
exceptionNone
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_namewrite
param{'write_string': '?123456789', 'is_shift': False}
time2022-03-28 09:52:29.496576
exception'AutoControlKeyboardException("keyboard write error AutoControlKeyboardException(\'keyboard write error cant find key\')")'
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Test Report
function_namewrite
param{'write_string': '!#@L@#{@#PL#{!@#L{!#{|##PO}!@#O@!O#P!)KI#O_!K', 'is_shift': False}
time2022-03-28 09:52:29.496576
exception'AutoControlKeyboardException("keyboard write error AutoControlKeyboardException(\'keyboard write error cant find key\')")'
+
+ + \ No newline at end of file diff --git a/test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py b/test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py index e4572b4b..7dea5406 100644 --- a/test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py +++ b/test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py @@ -38,4 +38,3 @@ generate_html("test") - diff --git a/test/unit_test/total_record_test/total_record_test.py b/test/unit_test/total_record_test/total_record_test.py index 3c96833f..88bfc401 100644 --- a/test/unit_test/total_record_test/total_record_test.py +++ b/test/unit_test/total_record_test/total_record_test.py @@ -35,3 +35,4 @@ print(test_record.total_record_list) + From d8f31f312c1a692a1e81594ff60147134e5a9e32 Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Mon, 28 Mar 2022 10:23:36 +0800 Subject: [PATCH 14/15] update dev version now error table on html report generator will mark test report head as red --- .idea/workspace.xml | 14 +- dev_setup.py | 2 +- .../utils/html_report/html_report_generate.py | 41 +- .../test.html | 388 ------------------ 4 files changed, 35 insertions(+), 410 deletions(-) delete mode 100644 test/integrated_test/total_record_and_html_report_test/test.html diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 95471576..f686fa7b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,14 +2,10 @@ - - - - - - - + + + @@ -449,7 +445,7 @@ - + diff --git a/dev_setup.py b/dev_setup.py index a90dcc8d..1d5ba16b 100644 --- a/dev_setup.py +++ b/dev_setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="je_auto_control_dev", - version="0.0.12", + version="0.0.14", author="JE-Chen", author_email="zenmailman@gmail.com", description="auto testing", diff --git a/je_auto_control/utils/html_report/html_report_generate.py b/je_auto_control/utils/html_report/html_report_generate.py index 29b97983..c26a65b0 100644 --- a/je_auto_control/utils/html_report/html_report_generate.py +++ b/je_auto_control/utils/html_report/html_report_generate.py @@ -38,6 +38,13 @@ font-family: "Times New Roman", sans-serif; text-align: center; }} + + .failure_table_head {{ + border: 3px solid #262626; + background-color: #f84c5f; + font-family: "Times New Roman", sans-serif; + text-align: center; + }} .table_data_field_title {{ border: 3px solid #262626; @@ -79,7 +86,7 @@ - + @@ -105,6 +112,22 @@ """.strip() +def make_html_table(event_str: str, record_data: dict, table_head: str): + event_str = "".join( + [ + event_str, + event_table.format( + table_head_class=table_head, + function_name=record_data.get("function_name"), + param=record_data.get("local_param"), + time=record_data.get("time"), + exception=record_data.get("program_exception"), + ) + ] + ) + return event_str + + def generate_html(html_name: str = "default_name"): """ :param html_name: save html file name @@ -115,17 +138,11 @@ def generate_html(html_name: str = "default_name"): else: event_str = "" for record_data in test_record.total_record_list: - event_str = "".join( - [ - event_str, - event_table.format( - function_name=record_data.get("function_name"), - param=record_data.get("local_param"), - time=record_data.get("time"), - exception=record_data.get("program_exception"), - ) - ] - ) + # because data on record_data all is str + if record_data.get("program_exception") == "None": + event_str = make_html_table(event_str, record_data, "event_table_head") + else: + event_str = make_html_table(event_str, record_data, "failure_table_head") new_html_string = html_string.format(event_table=event_str) try: lock.acquire() diff --git a/test/integrated_test/total_record_and_html_report_test/test.html b/test/integrated_test/total_record_and_html_report_test/test.html deleted file mode 100644 index 7f2c7c9d..00000000 --- a/test/integrated_test/total_record_and_html_report_test/test.html +++ /dev/null @@ -1,388 +0,0 @@ - - - - - AutoControl Report - - - - -

- Test Report -

-
Test ReportTest Report
- - - - - - - - - - - - - - - - - - - - - - - -
Test Report
function_namepress_key
param{'keycode': 'shift', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.464086
exceptionNone
-
- - - - - - - - - - - - - - - - - - - - - - - -
Test Report
function_namewrite
param{'write_string': '123456789', 'is_shift': False}
time2022-03-28 09:52:29.469092
exceptionNone
-
- - - - - - - - - - - - - - - - - - - - - - - -
Test Report
function_namepress_key
param{'keycode': 'return', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.469092
exceptionNone
-
- - - - - - - - - - - - - - - - - - - - - - - -
Test Report
function_namerelease_key
param{'keycode': 'return', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.470093
exceptionNone
-
- - - - - - - - - - - - - - - - - - - - - - - -
Test Report
function_namewrite
param{'write_string': 'abcdefghijklmnopqrstuvwxyz', 'is_shift': False}
time2022-03-28 09:52:29.483132
exceptionNone
-
- - - - - - - - - - - - - - - - - - - - - - - -
Test Report
function_namerelease_key
param{'keycode': 'shift', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.483132
exceptionNone
-
- - - - - - - - - - - - - - - - - - - - - - - -
Test Report
function_namepress_key
param{'keycode': 'return', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.483132
exceptionNone
-
- - - - - - - - - - - - - - - - - - - - - - - -
Test Report
function_namerelease_key
param{'keycode': 'return', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.483132
exceptionNone
-
- - - - - - - - - - - - - - - - - - - - - - - -
Test Report
function_namewrite
param{'write_string': 'abcdefghijklmnopqrstuvwxyz', 'is_shift': False}
time2022-03-28 09:52:29.496576
exceptionNone
-
- - - - - - - - - - - - - - - - - - - - - - - -
Test Report
function_namepress_key
param{'keycode': 'return', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.496576
exceptionNone
-
- - - - - - - - - - - - - - - - - - - - - - - -
Test Report
function_namerelease_key
param{'keycode': 'return', 'is_shift': False, 'skip_record': False}
time2022-03-28 09:52:29.496576
exceptionNone
-
- - - - - - - - - - - - - - - - - - - - - - - -
Test Report
function_namewrite
param{'write_string': '?123456789', 'is_shift': False}
time2022-03-28 09:52:29.496576
exception'AutoControlKeyboardException("keyboard write error AutoControlKeyboardException(\'keyboard write error cant find key\')")'
-
- - - - - - - - - - - - - - - - - - - - - - - -
Test Report
function_namewrite
param{'write_string': '!#@L@#{@#PL#{!@#L{!#{|##PO}!@#O@!O#P!)KI#O_!K', 'is_shift': False}
time2022-03-28 09:52:29.496576
exception'AutoControlKeyboardException("keyboard write error AutoControlKeyboardException(\'keyboard write error cant find key\')")'
-
- - \ No newline at end of file From ac91a5c21c6416cf3c2386d21dee034a3f498fa9 Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Mon, 28 Mar 2022 10:27:57 +0800 Subject: [PATCH 15/15] update stable version update stable version --- .idea/workspace.xml | 5 +---- dev_setup.py | 2 ++ setup.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f686fa7b..2712e5c7 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,10 +2,7 @@ - - - diff --git a/dev_setup.py b/dev_setup.py index 1d5ba16b..f3604570 100644 --- a/dev_setup.py +++ b/dev_setup.py @@ -34,3 +34,5 @@ # python dev_setup.py sdist bdist_wheel # python -m twine upload dist/* + + diff --git a/setup.py b/setup.py index 8542805a..7185a60a 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="je_auto_control", - version="0.0.82", + version="0.0.83", author="JE-Chen", author_email="zenmailman@gmail.com", description="auto testing",