Skip to content

Commit

Permalink
Remove reconnection in activity (#44)
Browse files Browse the repository at this point in the history
* delete reconnection releated codes in MainActivity

* fix py script

* change selenium version

* remove tests for deprecated class

---------

Co-authored-by: burak-58 <[email protected]>
  • Loading branch information
burak-58 and burak-58 authored Nov 19, 2023
1 parent 4142ca1 commit 41f5c5d
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 362 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ jobs:
python-version: '3.9'

- name: Install python packages
run: pip3 install requests selenium==3.141.0 flask webdriver-manager


run: |
wget https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/119.0.6045.105/linux64/chromedriver-linux64.zip
unzip chromedriver-linux64.zip
cp chromedriver-linux64/chromedriver /home/ubuntu
pip3 install requests selenium==4.14 flask
- name: Run Multitrack Conference Test Server
run: python3 multitrack-conference-server.py &

Expand All @@ -60,7 +63,7 @@ jobs:
script: |
touch emulator.log
chmod 777 emulator.log
adb logcat >> emulator.log &
adb logcat io.antmedia:I >> emulator.log &
./gradlew jacocoTestReport; EXIT_CODE=$?; exit $EXIT_CODE
- name: Archive Test Report
Expand All @@ -72,6 +75,7 @@ jobs:
webrtc-android-sample-app/build/reports/tests/testDebugUnitTest/
webrtc-android-sample-app/build/reports/jacoco/jacocoTestReport/
webrtc-android-sample-app/build/reports/androidTests/
webrtc-android-sample-app/build/outputs/connected_android_test_additional_output/
webrtc-android-framework/build/reports/tests/testDebugUnitTest/
webrtc-android-framework/build/reports/jacoco/jacocoTestReport/
webrtc-android-framework/build/reports/androidTests/
Expand Down
65 changes: 44 additions & 21 deletions multitrack-conference-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,36 @@
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from flask import Flask, request
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service




class Browser:
def init(self, is_headless):
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
chrome_options.add_argument("--use-fake-ui-for-media-stream")
chrome_options.add_argument("--use-fake-device-for-media-stream")
chrome_options.add_argument('--log-level=3')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-extensions')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--disable-setuid-sandbox')
browser_options = Options()
browser_options.add_experimental_option("detach", True)
browser_options.add_argument("--use-fake-ui-for-media-stream")
browser_options.add_argument("--use-fake-device-for-media-stream")
browser_options.add_argument('--log-level=3')
browser_options.add_argument('--no-sandbox')
browser_options.add_argument('--disable-extensions')
browser_options.add_argument('--disable-gpu')
browser_options.add_argument('--disable-dev-shm-usage')
browser_options.add_argument('--disable-setuid-sandbox')
if is_headless:
chrome_options.add_argument("--headless")

browser_options.add_argument("--headless")
dc = DesiredCapabilities.CHROME.copy()
dc['goog:loggingPrefs'] = { 'browser':'ALL' }

service = Service(executable_path='/home/ubuntu/chromedriver')
#service = Service(executable_path='C:/WebDriver/chromedriver.exe')

self.driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=chrome_options)
self.driver = webdriver.Chrome(service=service, options=browser_options)

def open_in_new_tab(self, url, tab_id):
self.driver.switch_to.window(self.driver.window_handles[0])
self.driver.execute_script("window.open('about:blank', '"+tab_id+"');")
print (self.driver.window_handles)
self.driver.switch_to.window(tab_id)
Expand All @@ -57,6 +61,9 @@ def write_to_element(self, element, text):
def click_element(self, element):
element.click()

def switch_to_tab(self, tab_id):
self.driver.switch_to.window(tab_id)

def close(self):
self.driver.close()

Expand All @@ -75,29 +82,45 @@ def close_all(self):

@app.route('/create', methods=['GET'])
def create():
# room = request.args.get('room')
chrome.open_in_new_tab(url, "p1")
room = request.args.get('room')
test = request.args.get('test')
participant = request.args.get('participant')
print("\n create for room:"+room+":"+participant+" in "+test)
chrome.open_in_new_tab(url+"?roomId="+room+"&streamId="+participant, participant)
return f'Room created', 200

@app.route('/join', methods=['GET'])
def join():
room = request.args.get('room')
test = request.args.get('test')
participant = request.args.get('participant')
print("\n join for room:"+room+":"+participant+" in "+test)
chrome.switch_to_tab(participant)
join_button = chrome.get_element_by_id("join_publish_button")
join_button.click()
return f'Joined the room', 200

@app.route('/leave', methods=['GET'])
def leave():
room = request.args.get('room')
test = request.args.get('test')
participant = request.args.get('participant')
print("\n leave for room:"+room+":"+participant+" in "+test)
chrome.switch_to_tab(participant)
leave_button = chrome.get_element_by_id("stop_publish_button")
leave_button.click()
return f'Left the room', 200

@app.route('/delete', methods=['GET'])
def delete():
#chrome.close()
#return f'Tab closed', 200
for handle in chrome.window_handles:
chrome.switch_to.window(handle)
chrome.close()
room = request.args.get('room')
test = request.args.get('test')
participant = request.args.get('participant')
print("\n delete for room:"+room+":"+participant+" in "+test)
chrome.switch_to_tab(participant)
chrome.close()
return f'Tab closed', 200


if __name__ == '__main__':
app.run(host='0.0.0.0', port=3030)
1 change: 1 addition & 0 deletions webrtc-android-sample-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ android {
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments useTestStorageService: "true"

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.GrantPermissionRule;

import org.apache.commons.lang3.RandomStringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -52,6 +53,7 @@ public class ConferenceActivityTest {
@Rule
public GrantPermissionRule permissionRule
= GrantPermissionRule.grant(AbstractSampleSDKActivity.REQUIRED_PUBLISH_PERMISSIONS);
private String roomName;

@Before
public void before() {
Expand Down Expand Up @@ -93,12 +95,13 @@ protected void finished(Description description) {
@Test
public void testJoinConfereceActivity() {
Intent intent = new Intent(ApplicationProvider.getApplicationContext(), ConferenceActivity.class);

roomName = "room_"+RandomStringUtils.randomNumeric(3);
ActivityScenario<ConferenceActivity> scenario = ActivityScenario.launch(intent);

scenario.onActivity(new ActivityScenario.ActivityAction<ConferenceActivity>() {
@Override
public void perform(ConferenceActivity activity) {
SettingsActivity.changeRoomName(activity, roomName);
mIdlingResource = activity.getIdlingResource();
IdlingRegistry.getInstance().register(mIdlingResource);
activity.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
Expand Down
Loading

0 comments on commit 41f5c5d

Please sign in to comment.