Bug 119085

Summary: [EFL][WK2] Simplify context_menu_spelling_items_availability unit test
Product: WebKit Reporter: Grzegorz Czajkowski <g.czajkowski>
Component: WebKit EFLAssignee: Grzegorz Czajkowski <g.czajkowski>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, commit-queue, gyuyoung.kim, gyuyoung.kim, lucas.de.marchi, rakuco
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
proposed patch
none
verify return value of each findContextMenuItem call
none
apply Gyuyoung's review gyuyoung.kim: review+

Description Grzegorz Czajkowski 2013-07-25 06:36:29 PDT
Use findContextMenuItem method to check whether the item appears in context menu.
Comment 1 Grzegorz Czajkowski 2013-07-25 06:40:07 PDT
Created attachment 207454 [details]
proposed patch
Comment 2 Gyuyoung Kim 2013-07-25 17:20:38 PDT
Comment on attachment 207454 [details]
proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=207454&action=review

LGTM.

> Source/WebKit2/ChangeLog:13
> +        Do not report failure here. It doesn't allow to test the negative test cases.

Shouldn't you need to check if existing uses of findContextMenuItem() are also failed ?
Comment 3 Gyuyoung Kim 2013-07-25 17:22:29 PDT
(In reply to comment #2)
> (From update of attachment 207454 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=207454&action=review
> 
> LGTM.

LGTM except for my question.
Comment 4 Grzegorz Czajkowski 2013-07-26 00:11:47 PDT
Comment on attachment 207454 [details]
proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=207454&action=review

>> Source/WebKit2/ChangeLog:13
>> +        Do not report failure here. It doesn't allow to test the negative test cases.
> 
> Shouldn't you need to check if existing uses of findContextMenuItem() are also failed ?

Present findContextMenuItem is being used to test the positive test cases only. Therefore it doesn't reach the 'error block' (ADD_FAILURE; return 0;)
IMHO we should check result of findContextMenuItem in the test/callback instead of reporting failure inside. It prevents us to use the method to test negative test cases.

Actually, the unit tests use findContextMenuItem to find an appropriate context menu item and to select it. The result of selected item is verified inside the tests. Assuming the positive test case, if findContextMenuItem fails the test will fail as well - the item won't be selected and the expected result will be different as well.

The reason of introducing ADD_FAILURE() in findContextMenuItem was to report failure earlier.
Comment 5 Gyuyoung Kim 2013-07-26 02:15:06 PDT
(In reply to comment #4)

> Actually, the unit tests use findContextMenuItem to find an appropriate context menu item and to select it. The result of selected item is verified inside the tests. Assuming the positive test case, if findContextMenuItem fails the test will fail as well - the item won't be selected and the expected result will be different as well.
> 
> The reason of introducing ADD_FAILURE() in findContextMenuItem was to report failure earlier.

I see. As we talk on irc, my question was that we need to check the result of findContextMenuItem() in other functions as well.
Comment 6 Grzegorz Czajkowski 2013-07-26 02:35:28 PDT
Created attachment 207519 [details]
verify return value of each findContextMenuItem call
Comment 7 Gyuyoung Kim 2013-07-26 03:01:32 PDT
Comment on attachment 207519 [details]
verify return value of each findContextMenuItem call

View in context: https://bugs.webkit.org/attachment.cgi?id=207519&action=review

> Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:295
> +        EXPECT_TRUE(spellingAndGrammarSubmenu);

Isn't checkSpellingWhileTypingItem instead of spellingAndGrammarSubmenu ?
Comment 8 Grzegorz Czajkowski 2013-07-26 03:11:37 PDT
Comment on attachment 207519 [details]
verify return value of each findContextMenuItem call

View in context: https://bugs.webkit.org/attachment.cgi?id=207519&action=review

>> Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:295
>> +        EXPECT_TRUE(spellingAndGrammarSubmenu);
> 
> Isn't checkSpellingWhileTypingItem instead of spellingAndGrammarSubmenu ?

Ooops. You're right. I'll fix it.
Comment 9 Grzegorz Czajkowski 2013-07-26 03:21:43 PDT
Created attachment 207520 [details]
apply Gyuyoung's review
Comment 10 Gyuyoung Kim 2013-07-26 10:34:02 PDT
Comment on attachment 207520 [details]
apply Gyuyoung's review

View in context: https://bugs.webkit.org/attachment.cgi?id=207520&action=review

> Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:-559
> -        ecore_main_loop_iterate();

When I ask EFL community this function, I could get this reply....
"DO NOT use this function unless you are the person God comes to ask for advice when He has trouble managing the Universe"

Hey, greg, ryuan and chris, let's think about this function. As we know, we are not GOD. ;)
Comment 11 Gyuyoung Kim 2013-07-26 10:39:22 PDT
(In reply to comment #10)
> (From update of attachment 207520 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=207520&action=review
> 
> > Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:-559
> > -        ecore_main_loop_iterate();
> 
> When I ask EFL community this function, I could get this reply....
> "DO NOT use this function unless you are the person God comes to ask for advice when He has trouble managing the Universe"

"DO NOT use this function unless you are the person God comes to ask for advice when He has trouble managing the Universe"

Frankly speaking, I got this comment from EFL docs, not efl irc or mailing list...........Plz let me know if this comment is incorrect.
Comment 12 Chris Dumez 2013-07-26 10:44:20 PDT
(In reply to comment #11)
> (In reply to comment #10)
> > (From update of attachment 207520 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=207520&action=review
> > 
> > > Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:-559
> > > -        ecore_main_loop_iterate();
> > 
> > When I ask EFL community this function, I could get this reply....
> > "DO NOT use this function unless you are the person God comes to ask for advice when He has trouble managing the Universe"
> 
> "DO NOT use this function unless you are the person God comes to ask for advice when He has trouble managing the Universe"
> 
> Frankly speaking, I got this comment from EFL docs, not efl irc or mailing list...........Plz let me know if this comment is incorrect.

We are using this function in the API tests, I don't think this is a big deal.
Anyway, this part of the patch does not really get rid of ecore_main_loop_iterate(), it merely hides it.
Comment 13 Grzegorz Czajkowski 2013-07-26 12:13:07 PDT
Comment on attachment 207520 [details]
apply Gyuyoung's review

View in context: https://bugs.webkit.org/attachment.cgi?id=207520&action=review

>>>> Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:-559
>>>> -        ecore_main_loop_iterate();
>>> 
>>> When I ask EFL community this function, I could get this reply....
>>> "DO NOT use this function unless you are the person God comes to ask for advice when He has trouble managing the Universe"
>>> 
>>> Hey, greg, ryuan and chris, let's think about this function. As we know, we are not GOD. ;)
>> 
>> "DO NOT use this function unless you are the person God comes to ask for advice when He has trouble managing the Universe"
>> 
>> Frankly speaking, I got this comment from EFL docs, not efl irc or mailing list...........Plz let me know if this comment is incorrect.
> 
> We are using this function in the API tests, I don't think this is a big deal.
> Anyway, this part of the patch does not really get rid of ecore_main_loop_iterate(), it merely hides it.

Yeah, using ecore_main_loop_iterate() in unit tests shouldn't affect the Universe ;)
As Chris said, we are using it in many aspects and replacing it with waitUntilTrue() is rather to match consistency with other tests which already use it.
Comment 14 Gyuyoung Kim 2013-07-28 13:49:26 PDT
(In reply to comment #13)

> > We are using this function in the API tests, I don't think this is a big deal.
> > Anyway, this part of the patch does not really get rid of ecore_main_loop_iterate(), it merely hides it.
> 
> Yeah, using ecore_main_loop_iterate() in unit tests shouldn't affect the Universe ;)
> As Chris said, we are using it in many aspects and replacing it with waitUntilTrue() is rather to match consistency with other tests which already use it.

Ok, let's replace it with waitUntilTrue() from now on.
Comment 15 Grzegorz Czajkowski 2013-07-29 00:16:10 PDT
Committed r153419: <http://trac.webkit.org/changeset/153419>