Example #1
0
        public void DeleteUserMultipleTimes()
        {
            const int maxCalls    = 100;
            int       actualCalls = 0;
            var       client      = _testController.RoomService;

            OperationCallback <object> handler = (error, state) =>
            {
                var userState = (object[])state;
                var call      = (int)userState[0];
                var startTime = (DateTime)userState[1];
                var elapsed   = DateTime.Now - startTime;
                actualCalls++;
                ClientLogger.Debug("Processing delete user call #{0}; actual call = {1}, recentElapsed time = {2} ms", call, actualCalls, elapsed.TotalMilliseconds);
                Assert.IsNull(error);
            };

            // Kick everything off.
            JoinRoom(error =>
            {
                for (int i = 0; i < maxCalls; i++)
                {
                    ClientLogger.Debug("Queueing delete user call #{0}", i);
                    ThreadPool.QueueUserWorkItem(o =>
                    {
                        var callNumber = (int)o;
                        var startTime  = DateTime.Now;
                        ClientLogger.Debug("Executing delete user call #{0}", callNumber);
                        client.DeleteUser(Guid.NewGuid(), handler, new object[] { callNumber, startTime });
                    }, i);
                }
            });
            EnqueueConditional(() => actualCalls >= maxCalls);
            EnqueueTestComplete();
        }
Example #2
0
        public Operation(string operationId, DrContext context, OperationCallback canExecute, OperationCallback onOperationFinished)
        {
            ArgumentCheck.Assigned (context, "context");

            opId = operationId;

            this.context = context;
            CanExecuteCallback = canExecute;
            OnOperationFinished = onOperationFinished;
        }
Example #3
0
        internal static IAsyncResult BeginOperation(OperationCallback operation,
                                                    AsyncCallback callback, object state)
        {
            var ar = new AsyncResult <T>(callback, state);

            ThreadPool.QueueUserWorkItem(delegate(object self)
            {
                try { ar.Result = operation(); }
                catch (Exception e) { ar.Exception = e; }
                ar.Complete();
            }, ar);
            return(ar);
        }
Example #4
0
 protected void JoinRoom(OperationCallback callback)
 {
     UpdateRepository(TestGlobals.NamedRoom, TestGlobals.User);
     _localUserVm.Login(_userTag, _password, loginError =>
     {
         Assert.IsNull(loginError);
         _roomVm.SessionId = Guid.NewGuid();
         _roomVm.JoinRoom(joinError =>
         {
             if (callback != null)
             {
                 callback(joinError);
             }
         });
     });
 }
        private void GetNavigationCommandFactory(string ownerUserTag, string roomName, string userTag, LoginSession loginSession, Action <TestExecResult> callback)
        {
            _localUserVm.UserTag      = userTag;
            _localUserVm.LoginSession = loginSession;
            _roomVm.UserTag           = ownerUserTag;
            _roomVm.RoomName          = roomName;
            var navCommandFactory = new JoinRoomController(_roomService, _viewModelFactory);

            Action <string, string> navigationRequiredCallback = (cbOwnerUserTag, cbRoomName) => Try(() =>
            {
                Assert.IsFalse(string.IsNullOrEmpty(cbOwnerUserTag), "The Owner must not be null.");
                Assert.IsFalse(string.IsNullOrEmpty(cbRoomName), "The Room must not be null.");

                if (callback != null)
                {
                    callback(TestExecResult.RenavigationRequired);
                }
            });

            OperationCallback joinRoomCallback = ex => Try(() =>
            {
                Assert.IsNull(ex, "The JoinRoomController threw an exception: " + ex);
                Assert.IsNotNull(_roomVm.UserVm.Model, "The Owner must not be null.");
                Assert.IsNotNull(_roomVm.Model, "The Room must not be null.");
                Assert.IsNotNull(_localUserVm.Model, "The User must not be null.");
                Assert.AreEqual(_roomVm.UserTag, _roomVm.UserVm.Model.UserTag);
                Assert.AreEqual(_roomVm.RoomName, _roomVm.Model.Name);
                Assert.AreEqual(_roomVm.UserVm.Model.UserId, _roomVm.Model.User.UserId);
                Assert.AreEqual(_localUserVm.UserId, _localUserVm.Model.UserId);
                if (callback != null)
                {
                    callback(TestExecResult.ExecutionCompleted);
                }
            });

            navCommandFactory.Execute(navigationRequiredCallback, joinRoomCallback);
        }
Example #6
0
 protected void ExecuteTestFramework(OperationCallback callback)
 {
     _roomVm.SessionId = Guid.NewGuid();
     JoinRoom(callback);
 }
Example #7
0
        public void CreateUser(string userId, string userName, string password, OperationCallback <User> callback)
        {
            var user = GetRegisteredUser(userId, userName, password);

            _roomService.CreateUser(user, callback);
        }
Example #8
0
 internal HideNotificationEventArgs(OperationCallback callback)
 {
     Callback = callback;
 }
Example #9
0
        private void RequestHideNotification([NotNull] OperationNotificationBase notification, OperationCallback callback)
        {
            var notificationType = notification.GetType();

            _notificationsCounter.TryGetValue(notificationType, out var counter);
            _notificationsCounter[notificationType] = Math.Max(--counter, 0);

            if (counter == 0)
            {
                notification.Hide(this, callback);
            }
        }
Example #10
0
 public void LoginWithTwitter(string identifier, string ownerUserId, string roomName, OperationCallback callback)
 {
     throw new NotImplementedException();
 }
Example #11
0
 public void LoginWithFacebook(long facebookId, string userId, string ownerUserId, string roomName, OperationCallback callback)
 {
     throw new NotImplementedException();
 }
Example #12
0
 public void Login(string userId, string password, string ownerUserId, string roomName, OperationCallback callback)
 {
     throw new NotImplementedException();
 }
Example #13
0
 public PlayerListener(SpotifyMusicServiceDroid sms)
 {
     this.sms = sms;
     this.operationCallback = new OperationCallback(this);
 }
Example #14
0
        public void StartSendingAudioToRoom(string ownerUserTag, string host, List <byte[]> testFrames, bool sendLive, OperationCallback callback)
        {
            // What we should use when there's only one other person, and CPU is OK:
            // 16Khz, Speex, WebRtc at full strength
            var config = MediaConfig.Default;

            config.LocalSsrcId           = (ushort)rnd.Next(ushort.MinValue, ushort.MaxValue);
            config.AudioContextSelection = AudioContextSelection.HighQualityDirect;
            config.MediaServerHost       = host;

            // Create the media controller
            var playedAudioFormat = new AudioFormat();
            var mediaStatistics   = new TimingMediaStatistics();
            var mediaEnvironment  = new TestMediaEnvironment();
            var mediaConnection   = new RtpMediaConnection(config, mediaStatistics);
            var vqc = new VideoQualityController(MediaConfig.Default.LocalSsrcId);

            _mediaController = new MediaController(MediaConfig.Default, playedAudioFormat, mediaStatistics, mediaEnvironment, mediaConnection, vqc);

            // Create the audio sink adapter.
            _captureSource = new CaptureSource();
            _captureSource.VideoCaptureDevice = null;
            if (_captureSource.AudioCaptureDevice == null)
            {
                _captureSource.AudioCaptureDevice = CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice();
                if (_captureSource.AudioCaptureDevice == null)
                {
                    throw new InvalidOperationException("No suitable audio capture device was found");
                }
            }
            MediaDeviceConfig.SelectBestAudioFormat(_captureSource.AudioCaptureDevice);
            _captureSource.AudioCaptureDevice.AudioFrameSize = AudioFormat.Default.MillisecondsPerFrame;             // 20 milliseconds
            _audioSinkAdapter = sendLive
                                ? new AudioSinkAdapter(_captureSource, _mediaController, config, mediaEnvironment, playedAudioFormat)
                                : new FromFileAudioSinkAdapter(_captureSource, _mediaController, config, mediaEnvironment, playedAudioFormat, testFrames);

            var roomService = new RoomServiceAdapter();

            roomService.CreateClient();
            roomService.GetRoomId(Constants.DefaultCompanyTag, Constants.DefaultAuthenticationGroupTag, ownerUserTag, Constants.DefaultRoomName, (getRoomError, result) =>
            {
                if (getRoomError != null)
                {
                    callback(getRoomError);
                }
                else
                {
                    // Connect.
                    _mediaController.Connect(result.RoomId.ToString(), connectError => Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        if (connectError == null)
                        {
                            ClientLogger.Debug("MacTestViewModel connected to MediaController");
                            _captureSource.Start();
                        }
                        _mediaController.RegisterRemoteSession((ushort)(config.LocalSsrcId + 1));
                        callback(connectError);
                    }));
                }
            });
        }
Example #15
0
 protected internal abstract void Hide([NotNull] OperationContext context, OperationCallback callback);