Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SS): Implement test #121

Merged
merged 4 commits into from
Mar 3, 2018
Merged

feat(SS): Implement test #121

merged 4 commits into from
Mar 3, 2018

Conversation

hristoterezov
Copy link
Member

No description provided.

}
catch (IOException e)
{
e.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what ? shouldn't that fail the test ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will eventually fail the test probably anyway. How do you want to change it?

Copy link
Member

@paweldomas paweldomas Feb 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to wrap in RuntimeException and re-throw at least

throws IOException
{
URL website = new URL(
EXT_DOWNLOAD_URL_PREFIX + id + EXT_DOWNLOAD_URL_SUFIX);
Copy link
Member

@paweldomas paweldomas Feb 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use string format here ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How? My Java is a little rusty... What will be the benefit?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://dzone.com/articles/java-string-format-examples

It is weird that there are two constants for something which is actually one thing, where prefix is never used without the suffix.

It's possible that the % signs in the string would have to be escaped.

File extension = File.createTempFile("jidesha", ".crx");
extension.deleteOnExit();

FileOutputStream fos = new FileOutputStream(extension);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my java is a little bit rusty as I said. So could you please explain with more details? The part that puzzles me is I want this method to trow the exception.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but the purpose of using that is to close the resource, not to catch the IOException

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I'll read the docs more carefully!

public static Object getConfigValue(WebDriver participant, String key)
{
return ((JavascriptExecutor) participant)
.executeScript("return config." + key);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this approach for getting config parameters, because it requires alive and connected to an existing conference WebParticipant. I don't see any of such assumptions being mentioned anywhere around here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Could you be more specific which approach you would like for this situation? If you don't have better approach in mind, the current approach will be still the best....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably at least moving this method to WebParticipant, because having it there means that it belongs to web only.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@paweldomas
Copy link
Member

Why don't we go with PageObjects given the test is being rewritten ?

@hristoterezov
Copy link
Member Author

Why don't we go with PageObjects given the test is being rewritten ?

I have no idea what are you talking about! What is PageObjects?

@paweldomas
Copy link
Member

*/
void driverVideoLayoutTest(Participant participant)
void driverVideoLayoutTest(Participant participant, boolean isScreenSharing)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method is now superfluous (and the doc needs an update).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs are updated! I decided to leave it because in future we may want to add more stuff in it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs are updated!

I don't think this actually made it to the PR:

(this commit is the current head of master)

@damencho
Copy link
Member

I've added pr testing for torture now. And this one failed:
unknown error: cannot process extension #1
from unknown error: cannot extract magic number
(Driver info: chromedriver=2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881),platform=Linux 4.4.0-1050-aws x86_64) (WARNING: The server did not provide any stacktrace information)

We should handle the case if desktop sharing is not configured.

@hristoterezov
Copy link
Member Author

@paweldomas I don't see why we need to implement page object for tests that are running only on web. Especially for the desktop sharing test, we don't have any idea if this feature will ever be implemented for mobile and how it will look there. Even if we refactor it now we'll have to definitely refactor it later again when the functionality is implemented for mobile. I think that for desktop sharing test adding page objects will be waste of time (3 times refactoring/rewriting). At the end if there is a desktop sharing for mobile, it can be so different that we may even need totally different test.

I'm sorry if I misunderstood the idea behind the page objects! Please correct me if I'm wrong!

@paweldomas
Copy link
Member

The ChatPanel test is currently only for web too, so I don't find this argument relevant. I will try to be more specific and comment on each place where that would be suitable and we can continue the discussion from there.

ensureTwoParticipants(
null, null, null,
new WebParticipantOptions().setChromeExtensionId(
(String) MeetUtils.getConfigValue(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move getConfigValue method to WebParticipant ? Then you can call getParticipant1().getConfigValue(). Actually it could event be a method "getDesktopSharingExtensionId()" in the WebParticipantDirectly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I ask for that is that we're trying to go away from accessing the driver directly and using it with static utility functions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the previous comments. I've agreed with this and getConfigValue is already a moved to WebParticipant.


final String expectedResult = "desktop";
// holds the last retrieved value for the remote type
final Object[] remoteVideoType = new Object[1];
try
{
final String scriptToExecute = "return APP.UI.getRemoteVideoType('"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this script execution a "getRemoteVideoType" method in WebParticipant ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there other place where we are using this? I don't think so. That's why I think this belongs to the DesktopSharingTest!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it does not ! It belongs to the WebParticipant !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test class describes what is being tested and how. Who's video type is ? Participant's. In this particular case we're checking what video type given web participant has received for given remote participant through presence. Other tests can be also interested in checking that.

MeetUIUtils.clickOnToolbarButton(
getParticipant1().getDriver(), "toggleFilmstripButton");

TestUtils.waitMillis(5000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we waiting here for exactly ? Waits like this are waste of time and never check for the condition that is expected after the wait period is over.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will leave this for now like this. Hiding the filmstrip because of animations can take some time. We cannot check for a css change, cause currently, we change the css and after the change, it starts moving the filmstrip away from the screen for two seconds (which with the framebuffer can take more). We already spend a lot of time looking at it to figure it out. Maybe checking for isDisplayed of the local video is one solution will give it a quick try and if it doesn't work will leave the waits.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the purpose could be explained in a comment at least.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to wait for local video not displayed works. Will see how it goes. Will merge it after the tests pass.

MeetUIUtils.clickOnToolbarButton(
getParticipant1().getDriver(), "toggleFilmstripButton");

TestUtils.waitMillis(5000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again: what's the purpose of the wait here ?

*/
private void startDesktopSharing()
{
TestUtils.waitForElementByXPath(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this 3 statements in the PageObject world would be:
Toolbat toolbar = getParticipant2().getToolbar();
Button dsButton = toolbar.getDesktopsharingButton();
dsButton.click();
dsButton.assertToggled(true /* toggled /, 2 / timeout seconds */);
I don't know what would be the exact type of the Button. Maybe it's just WebElement. Or maybe we need a class the wraps it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the approach with getButton and then click is not good at all in the context of react. I would even say to skip searching for web element and getting them and then executing click. We already had such problems with the toolbars. The better approach is at the end to just execute document.getElementById('...').click();
https://github.com/jitsi/jitsi-meet-torture/blob/master/src/test/java/org/jitsi/meet/test/util/MeetUIUtils.java#L243
The problem is a StaleElementException coming from selenium. You take the element and try to click it, but by that time react has re-rendered the toolbar and that element is stale.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is a problem with saving the WebElement, and not a problem with the "getButton" abstraction itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's right, thanks for the clarification :)

*/
private void stopDesktopSharing()
{
TestUtils.waitForElementByXPath(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

private void checkExpandingDesktopSharingLargeVideo(boolean isScreenSharing)
{
// check layout
new VideoLayoutTest().driverVideoLayoutTest(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate that we need to create test instances somewhere else, but it would be probably too much to refactor this in this PR...

@hristoterezov
Copy link
Member Author

@paweldomas Thanks very much for the additional explanations. Maybe I was not very clear. My problem here is that I don't think we should use the PageObjects for this test. But let's discuss this offline because it seems like a longer discussion.

@paweldomas
Copy link
Member

@hristoterezov Why would we have two different ways of dealing with things ? Everything is "longer discussion" always. I keep hearing that all the time recently. We can discuss that on the retro or call a meeting.

@paweldomas
Copy link
Member

paweldomas commented Mar 1, 2018

@damencho we can do document.getElemntById on web inside of the Button or PageObject abstraction. But on mobile it will be a different way for getting WebElement (find by accessibility ID or something else).

@paweldomas
Copy link
Member

Btw. long time ago I was forbidden to rewrite whole torture into the PageObject concept and there was an agreement to do that step by step, so here we are. I am really getting frustrated about this attitude of getting shortcuts all the time and then someone else when adding new thing will have to deal with all that. You have just a couple of places to address. I'm not asking you to write full Toolbar or whatever -just the part you need (1 button ?).

TestUtils.waitMillis(5000);
TestUtils.waitForDisplayedElementByXPath(
getParticipant1().getDriver(),
"//span[@id='localVideoWrapper']",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this duplicates the constant and could be a TestUtil method, but I give up since you want to merge it now

private void testDesktopSharingInPresence(final String expectedResult)
{
String participant1Jid
= MeetUtils.getResourceJid(getParticipant2().getDriver());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name suggests this is the id of participant 1, but the code gets the id of participant 2. What is the intention?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No intention. It's a mistake! I should change the variable name!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm merging anyway and will change it

/**
* Stops desktop sharing.
*/
private void stopDesktopSharing()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

startDesktopSharing and stopDesktopSharing are exactly the same? Is this intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of. After the refactoring I end up implementing a method that handles both cases. Maybe I should remove the start/stopDesktopSharing and use the new method directly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm merging anyway and replaced the two methods with "toggleDesktopSharing"

@hristoterezov hristoterezov deleted the ss_test branch March 3, 2018 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants