示例#1
0
        public async Task AdminSectionShouldBeAvailableForAdminAfterLogin(bool userIsAdmin)
        {
            const string user = "******";
            const string pass = "******";

            Authentication.WhenUserIsKnown(user, pass, isAdmin: userIsAdmin);

            var vm = await GetSut();

            var loginVm = NavigationAdapter.Should().BeDisplaying <LoginViewModel>(true).Which;

            loginVm.User     = user;
            loginVm.Password = pass;
            loginVm.LoginCommand.Click();

            NavigationAdapter.Should().NotBeDisplaying <LoginViewModel>();
            NavigationAdapter.Should().BeDisplaying <MainPageViewModel>();

            if (userIsAdmin)
            {
                vm.NavigateToAdminCommand.Should().BeEnabled();
            }
            else
            {
                vm.NavigateToAdminCommand.Should().BeDisabled();
            }
        }
示例#2
0
        public void HandleCommandsChanged(Element playbin)
        {
            InDvdMenu = false;
            // Get available command to know if player is in menu
            // FIXME: GlobalVideo should be Gst.Video.Global
            Gst.Query query = Global.NavigationQueryNewCommands();

            NavigationCommand[] cmds;
            if (Navigation == null)
            {
                FindNavigation(playbin);
            }
            if (!(NavigationElement.Query(query) && NavigationAdapter.ParseCommands(query, out cmds)))
            {
                return;
            }
            foreach (NavigationCommand cmd in cmds)
            {
                switch (cmd)
                {
                case NavigationCommand.Activate:
                case NavigationCommand.Left:
                case NavigationCommand.Right:
                case NavigationCommand.Up:
                case NavigationCommand.Down:
                    InDvdMenu = true;
                    break;

                default:
                    break;
                }
            }
        }
示例#3
0
        public async Task CanLoginWithKnownUserAndPassword()
        {
            await LoginHappyPath();

            Authentication.Should().BeLoggedIn();
            NavigationAdapter.Should().NotBeDisplaying <LoginViewModel>();
        }
        public async Task CanChangePassword()
        {
            await RunHappyPath(
                o => CredentialService.PasswordChanged.Should().BeFalse());

            CredentialService.PasswordChanged.Should().BeTrue();
            NavigationAdapter.Should().NotBeDisplaying <PasswordChangeViewModel>();
        }
示例#5
0
        public async Task LogoutLeadsToLogin()
        {
            Authentication.WhenUserIsLoggedIn();

            (await GetSut()).LogoutCommand.Click();

            Authentication.Should().NotBeLoggedIn();
            NavigationAdapter.Should().BeDisplaying <LoginViewModel>(true);
        }
示例#6
0
 private void DestroyNavigationAdapter()
 {
     if (_navigationAdapter != null)
     {
         _navigationAdapter.UninitializeNavigationService();
         _navigationAdapter.NavigatedTo    -= OnNavigatedTo;
         _navigationAdapter.NavigatingAway -= OnNavigatingAway;
         _navigationAdapter.NavigatedAway  -= OnNavigatedAway;
         _navigationAdapter = null;
     }
 }
示例#7
0
        public async Task AdminCanNavigateToAdminOverview()
        {
            Authentication.WhenAdminIsLoggedIn();

            var vm = await GetSut();

            vm.IsAdmin.Should().BeTrue();
            vm.NavigateToAdminCommand.Should().BeEnabled();
            vm.NavigateToAdminCommand.Click();

            NavigationAdapter.Should().BeDisplaying <OverviewViewModel>();
        }
示例#8
0
        private void CreateNavigationAdapter(bool comingFromLoadedEvent)
        {
            if (_navigationAdapter == null)
            {
                _navigationAdapter                 = new NavigationAdapter(TargetPage);
                _navigationAdapter.NavigatedTo    += OnNavigatedTo;
                _navigationAdapter.NavigatingAway += OnNavigatingAway;
                _navigationAdapter.NavigatedAway  += OnNavigatedAway;

                if (comingFromLoadedEvent)
                {
                    OnNavigatedTo(this, new NavigatedEventArgs(_navigationAdapter.GetNavigationUriForTargetPage(), NavigationMode.New));
                }
            }
        }
        /// <summary>
        /// Navigates the to the given fragment.
        /// </summary>
        /// <param name="fragment">Fragment.</param>
        private void GotoFragment(Fragment fragment, Drawable drawable)
        {
            // Ensure that the fragment stack is clear.

            var ft = FragmentManager.BeginTransaction();

            ft.SetCustomAnimations(Resource.Animation.enter, Resource.Animation.exit);

            ft.Replace(Resource.Id.content, fragment);
            activeFragment = fragment;

            ft.Commit();

            drawerList.Adapter = navigationAdapter = new NavigationAdapter(BuildNavigationItems(), cache);

            ActionBar.SetLogo(drawable);
        }
示例#10
0
        private async Task <LoginViewModel> LoginHappyPath(Action <HappyPathOptions> setup = null, Action <HappyPathOptions> beforeLogin = null)
        {
            var options = new HappyPathOptions();

            setup?.Invoke(options);

            Authentication.WhenUserIsKnown(options.User, options.Pass, options.NeedsPasswordChange, options.IsAdmin);

            beforeLogin?.Invoke(options);

            var vm = await GetSut();

            NavigationAdapter.Should().BeDisplaying <LoginViewModel>();

            Login(vm, options.User, options.Pass);

            return(vm);
        }
示例#11
0
        public async Task ShouldReturnToMainPageAfterLogin()
        {
            const string user = "******";
            const string pass = "******";

            Authentication.WhenUserIsKnown(user, pass);

            await GetSut();

            var loginVm = NavigationAdapter.Should().BeDisplaying <LoginViewModel>(true).Which;

            loginVm.User     = user;
            loginVm.Password = pass;
            loginVm.LoginCommand.Click();

            NavigationAdapter.Should().NotBeDisplaying <LoginViewModel>();
            NavigationAdapter.Should().BeDisplaying <MainPageViewModel>();
        }
示例#12
0
        private void CreateNavigationAdapter(bool comingFromLoadedEvent)
        {
            if (_navigationAdapter == null)
            {
                var serviceLocator    = this.GetServiceLocator();
                var navigationService = serviceLocator.ResolveType <INavigationRootService>();
                var navigationRoot    = navigationService.GetNavigationRoot();

                _navigationAdapter                 = new NavigationAdapter(TargetPage, navigationRoot);
                _navigationAdapter.NavigatedTo    += OnNavigatedTo;
                _navigationAdapter.NavigatingAway += OnNavigatingAway;
                _navigationAdapter.NavigatedAway  += OnNavigatedAway;

                if (comingFromLoadedEvent)
                {
                    OnNavigatedTo(this, new NavigatedEventArgs(_navigationAdapter.GetNavigationUriForTargetPage(), NavigationMode.New));
                }
            }
        }
示例#13
0
        public void FindNavigation(Element playbin)
        {
            Element     video_sink = null;
            INavigation previous_navigation;

            previous_navigation = Navigation;
            video_sink          = playbin ["video-sink"] as Element;

            if (video_sink == null)
            {
                Navigation = null;
                if (previous_navigation != null)
                {
                    previous_navigation = null;
                }
            }

            NavigationElement = (video_sink is Bin)
                ? ((Bin)video_sink).GetByInterface(NavigationAdapter.GType)
                : video_sink;
            Navigation = NavigationAdapter.GetObject(NavigationElement);
        }
        private async Task <PasswordChangeViewModel> RunHappyPath(Action <HappyPathOptions> setup = null,
                                                                  Action <PasswordChangeViewModel> beforeSetFieldValues = null,
                                                                  Action <HappyPathOptions, PasswordChangeViewModel> beforeChangePassword = null)
        {
            var options = new HappyPathOptions();

            setup?.Invoke(options);

            var vm = await GetSut();

            NavigationAdapter.Should().BeDisplaying <PasswordChangeViewModel>();

            beforeSetFieldValues?.Invoke(vm);

            vm.OldPassword        = options.OldPassword;
            vm.NewPassword        = options.NewPassword;
            vm.ConfirmNewPassword = options.ConfirmNewPassword;

            beforeChangePassword?.Invoke(options, vm);

            vm.ChangePasswordCommand.Click();

            return(vm);
        }
示例#15
0
        private void InitializeNavigationDrawer()
        {
            myDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.myLeftDrawer);
            myLeftDrawer   = FindViewById <ListView>(Resource.Id.LeftDrawer);
            myDrawerToggle = new ActionBarDrawerToggle(
                this,                           //host activity
                myDrawerLayout,                 //Layout
                Resource.String.openDrawer,     //Message when drawer is open
                Resource.String.closeDrawer);   //Message when drawer is closed


            foreach (var navigableActivity in CanNavigateTo)
            {
                SetupMenuItem(navigableActivity);
            }

            myDrawerToggle.SyncState();

            var myDrawerAdapter = new NavigationAdapter(this, myDrawerList);

            myLeftDrawer.Adapter    = myDrawerAdapter;
            myLeftDrawer.ItemClick += (sender, e) => OnNavigationItemClick(e.Position);
            myLeftDrawer.BringToFront();
        }
        public async Task CanRegisterNewUser()
        {
            var vm = await GetSut();

            NavigationAdapter.Should().BeDisplaying <AddUserViewModel>();

            vm.AddNewUserCommand.Should().BeDisabled();

            vm.EmailAddress    = "*****@*****.**";
            vm.Firstname       = "John";
            vm.Lastname        = "Doe";
            vm.Password        = "******";
            vm.ConfirmPassword = vm.Password;

            vm.AddNewUserCommand.Should().BeEnabled();

            vm.AddNewUserCommand.Click();

            vm.AddNewUserCommand.Should().BeDisabled();

            CredentialService.Should().HaveRegistered("John", "Doe");

            NavigationAdapter.Should().NotBeDisplaying <AddUserViewModel>();
        }
示例#17
0
        public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView (inflater, container, savedInstanceState);
            var view = inflater.Inflate (Resource.Layout.NavigationLayout, null, true);
            navigationListView = view.FindViewById<ListView> (Resource.Id.navigationListView);
            navigationStatus = view.FindViewById<Spinner> (Resource.Id.fragmentStatus);
            navigationStatusImage = view.FindViewById<ImageView> (Resource.Id.fragmentStatusImage);
            timerLayout = view.FindViewById<RelativeLayout> (Resource.Id.fragmentTimerTextLayout);
            navigationStatusLayout = view.FindViewById<LinearLayout> (Resource.Id.navigationStatusLayout);
            timer = view.FindViewById<ToggleButton> (Resource.Id.fragmentTimer);
            timerHours = view.FindViewById<TextView> (Resource.Id.fragmentHours);

            navigationStatusImage.SetImageResource (Resource.Drawable.HoldImage);
            var spinnerAdapter = new SpinnerAdapter<AssignmentStatus> (assignmentViewModel.AvailableStatuses, Activity, Resource.Layout.SimpleSpinnerItem);
            spinnerAdapter.TextColor = Color.White;
            navigationStatus.Adapter = spinnerAdapter;
            if (Assignment != null && !Assignment.IsHistory) {
                navigationStatus.ItemSelected += (sender, e) => {
                    var status = assignmentViewModel.AvailableStatuses [e.Position];
                    if (Assignment != null && Assignment.Status != status && Assignment.Status != AssignmentStatus.New) {
                        switch (status) {
                            case AssignmentStatus.Complete:
                                //go to confirmations screen
                                var currentPosition = navigationListView.SelectedItemPosition;
                                var confirmationPosition = Constants.Navigation.IndexOf ("Confirmations");
                                if (currentPosition != confirmationPosition) {
                                    navigationSelector.OnItemClick (navigationListView, navigationListView.GetChildAt (confirmationPosition), confirmationPosition, 0);
                                }
                                navigationStatus.SetSelection (assignmentViewModel.AvailableStatuses.ToList ().IndexOf (Assignment.Status));
                                break;
                            default:
                                Assignment.Status = status;
                                SaveAssignment ();
                                break;
                        }
                    }
                };
            }
            timerLayout.Visibility = ViewStates.Gone;

            var adapter = new NavigationAdapter (Activity, Resource.Layout.NavigationListItemLayout, Constants.Navigation);
            if (Assignment != null && Assignment.IsHistory) {
                adapter = new NavigationAdapter (Activity, Resource.Layout.NavigationListItemLayout, Constants.HistoryNavigation);
            }
            navigationListView.OnItemClickListener = navigationSelector;
            navigationListView.Adapter = adapter;

            timer.CheckedChange += (sender, e) => {
                if (e.IsChecked != assignmentViewModel.Recording) {
                    if (assignmentViewModel.Recording) {
                        assignmentViewModel.PauseAsync ();
                    } else {
                        assignmentViewModel.RecordAsync ();
                    }
                }
            };

            SetActiveAssignment ();

            return view;
        }
示例#18
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);
            var view = inflater.Inflate(Resource.Layout.NavigationLayout, null, true);

            navigationListView     = view.FindViewById <ListView> (Resource.Id.navigationListView);
            navigationStatus       = view.FindViewById <Spinner> (Resource.Id.fragmentStatus);
            navigationStatusImage  = view.FindViewById <ImageView> (Resource.Id.fragmentStatusImage);
            timerLayout            = view.FindViewById <RelativeLayout> (Resource.Id.fragmentTimerTextLayout);
            navigationStatusLayout = view.FindViewById <LinearLayout> (Resource.Id.navigationStatusLayout);
            timer      = view.FindViewById <ToggleButton> (Resource.Id.fragmentTimer);
            timerHours = view.FindViewById <TextView> (Resource.Id.fragmentHours);

            navigationStatusImage.SetImageResource(Resource.Drawable.HoldImage);
            var spinnerAdapter = new SpinnerAdapter <AssignmentStatus> (assignmentViewModel.AvailableStatuses, Activity, Resource.Layout.SimpleSpinnerItem);

            spinnerAdapter.TextColor = Color.White;
            navigationStatus.Adapter = spinnerAdapter;
            if (Assignment != null && !Assignment.IsHistory)
            {
                navigationStatus.ItemSelected += (sender, e) => {
                    var status = assignmentViewModel.AvailableStatuses [e.Position];
                    if (Assignment != null && Assignment.Status != status && Assignment.Status != AssignmentStatus.New)
                    {
                        switch (status)
                        {
                        case AssignmentStatus.Complete:
                            //go to confirmations screen
                            var currentPosition      = navigationListView.SelectedItemPosition;
                            var confirmationPosition = Constants.Navigation.IndexOf("Confirmations");
                            if (currentPosition != confirmationPosition)
                            {
                                navigationSelector.OnItemClick(navigationListView, navigationListView.GetChildAt(confirmationPosition), confirmationPosition, 0);
                            }
                            navigationStatus.SetSelection(assignmentViewModel.AvailableStatuses.ToList().IndexOf(Assignment.Status));
                            break;

                        default:
                            Assignment.Status = status;
                            SaveAssignment();
                            break;
                        }
                    }
                };
            }
            timerLayout.Visibility = ViewStates.Gone;

            var adapter = new NavigationAdapter(Activity, Resource.Layout.NavigationListItemLayout, Constants.Navigation);

            if (Assignment != null && Assignment.IsHistory)
            {
                adapter = new NavigationAdapter(Activity, Resource.Layout.NavigationListItemLayout, Constants.HistoryNavigation);
            }
            navigationListView.OnItemClickListener = navigationSelector;
            navigationListView.Adapter             = adapter;

            timer.CheckedChange += (sender, e) => {
                if (e.IsChecked != assignmentViewModel.Recording)
                {
                    if (assignmentViewModel.Recording)
                    {
                        assignmentViewModel.PauseAsync();
                    }
                    else
                    {
                        assignmentViewModel.RecordAsync();
                    }
                }
            };

            SetActiveAssignment();

            return(view);
        }
示例#19
0
        public async Task WhenNotLoggedInLoginViewGetsDisplayed()
        {
            await GetSut();

            NavigationAdapter.Should().BeDisplaying <LoginViewModel>(true);
        }
示例#20
0
        private bool OnBusMessage(Bus bus, Message msg)
        {
            switch (msg.Type)
            {
            case MessageType.Eos:
                StopIterating();
                Close(false);
                OnEventChanged(PlayerEvent.EndOfStream);

                OnEos();
                break;

            case MessageType.StateChanged:
                if (msg.Src == playbin)
                {
                    State old_state, new_state, pending_state;
                    msg.ParseStateChanged(out old_state, out new_state, out pending_state);
                    HandleStateChange(old_state, new_state, pending_state);
                }
                break;

            case MessageType.Buffering:
                int buffer_percent = msg.ParseBuffering();
                HandleBuffering(buffer_percent);
                break;

            case MessageType.Tag:
                TagList tag_list = msg.ParseTag();
                tag_list.Foreach(HandleTag);
                break;

            case MessageType.Error:
                GLib.GException err;
                string          debug;
                msg.ParseError(out err, out debug);

                HandleError(err);
                break;

            case MessageType.Element:

                if (Gst.PbUtils.Global.IsMissingPluginMessage(msg))
                {
                    string detail = Gst.PbUtils.Global.MissingPluginMessageGetInstallerDetail(msg);

                    if (detail == null)
                    {
                        return(false);
                    }

                    if (missing_details.Contains(detail))
                    {
                        Log.DebugFormat("Ignoring missing element details, already prompted ('{0}')", detail);
                        return(false);
                    }

                    Log.DebugFormat("Saving missing element details ('{0}')", detail);
                    missing_details.Add(detail);

                    Log.Error("Missing GStreamer Plugin", Gst.PbUtils.Global.MissingPluginMessageGetDescription(msg), true);

                    InstallPluginsContext install_context = new InstallPluginsContext();
                    Gst.PbUtils.Global.InstallPluginsAsync(missing_details.ToArray(), install_context, OnInstallPluginsReturn);
                }
                else if (NavigationAdapter.MessageGetType(msg) == NavigationMessageType.CommandsChanged)
                {
                    dvd_manager.HandleCommandsChanged(playbin);
                }
                break;

            case MessageType.StreamStart:
                HandleStreamStart();
                break;

            case MessageType.Application:
                string    name;
                Structure s = msg.Structure;
                name = s.Name;
                if (String.IsNullOrEmpty(name) && name == "stream-changed")
                {
                    video_manager.ParseStreamInfo();
                }
                break;
            }

            return(true);
        }
示例#21
0
        public async Task DisplayPasswordChangeWhenPasswordShouldBeChangedAfterLogin()
        {
            await LoginHappyPath(setup : o => o.NeedsPasswordChange = true);

            NavigationAdapter.Should().BeDisplaying <PasswordChangeViewModel>(true);
        }
        // Overridden from Activity
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            if (AppState.context == null)
            {
                StartActivity(typeof(MainActivity));
                Finish();
                return;
            }

            SetContentView(Resource.Layout.activity_home);

            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);
            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.main);
            drawerToggle = new DrawerToggle(this, drawerLayout);
            drawerLayout.SetDrawerListener(drawerToggle);
            content    = FindViewById(Resource.Id.content);
            drawer     = FindViewById(Resource.Id.drawer);
            drawerList = FindViewById <ListView>(Resource.Id.drawer_list);
            drawerList.OnItemClickListener = this;
            drawerList.Adapter             = navigationAdapter = new NavigationAdapter(BuildNavigationItems(), cache);

            var up = FindViewById <ImageView>(Android.Resource.Id.Home);

            up.SetPadding(15, 0, 0, 0);

            var emptyText = new TextView(this);

            emptyText.Text       = GetString(Resource.String.app_no_navigation_items);
            drawerList.EmptyView = emptyText;

            var i = Intent;

            var show = i.GetStringExtra(EXTRA_SHOW_FRAGMENT);

            if (show == null)
            {
                show = SHOW_WORKBENCH;
            }

            switch (show)
            {
            case SHOW_WORKBENCH:
                DisplayWorkbench();
                break;

            default:
                Log.D(this, "SHOW_FRAGMENT extra value: " + show + " invalid. Defaulting to workbench");
                DisplayWorkbench();
                break;
            }

            if (ion.appPrefs.showTutorial)
            {
                StartActivity(new Intent(this, typeof(TutorialActivity)));
            }
            else if (!ion.version.Equals(ion.preferences.lastKnownAppVersion) /* && !ion.preferences.firstLaunch*/)
            {
                if (!"0.0.0".Equals(ion.preferences.lastKnownAppVersion))
                {
                    if (ion.appPrefs.showWhatsNew)
                    {
                        try {
                            new WhatsNewDialog(this, ion.appPrefs, AppVersion.ParseOrThrow(ion.preferences.lastKnownAppVersion), AppVersion.ParseOrThrow(ion.version)).Show();
                        } catch (Exception e) {
                            Log.E(this, "Failed to parse current app version {" + ion.version + "}", e);
                            Toast.MakeText(this, Resource.String.error_failed_to_show_whats_new, ToastLength.Long).Show();
                        }
                    }
                }
            }
            ion.preferences.lastKnownAppVersion = ion.version;

            // Show the rss feed.
            Task.Factory.StartNew(ion.portal.DownloadRssOrThrowAsync)
            .ContinueWith((args) => {
                var rss = args.Result.Result;
                try {
                    var items = new List <RssItem>();
                    for (int j = 0; j < rss.channels[0].items.Count; j++)
                    {
                        var item = rss.channels[0].items[j];
                        if (item.publishDate.CompareTo(ion.appPrefs.lastRssDate) >= 0 && DateTime.Now.CompareTo(item.expireDate) <= 0)
                        {
                            items.Add(item);
                        }
                    }

                    if (items.Count > 0)
                    {
                        ion.PostToMain(() => {
                            new RssDialog(this, rss).Show();
                            ion.appPrefs.lastRssDate = DateTime.Now;
                        });
                    }
                } catch (Exception e) {
                    Log.E(this, "Failed to download rss feed", e);
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }