Пример #1
0
        public void EmitsCorrectlyWhenPresentedOnBackPressed()
        {
            var detail = new BackButtonPage();
            var master = new BackButtonPage {
                Title = "Master"
            };
            var mdp = new MasterDetailPage
            {
                Detail            = detail,
                Master            = master,
                IsPresented       = true,
                IsPlatformEnabled = true,
            };

            ((IMasterDetailPageController)mdp).BackButtonPressed += (sender, args) =>
            {
                args.Handled    = mdp.IsPresented;
                mdp.IsPresented = false;
            };

            var detailEmitted = false;
            var masterEmitted = false;

            detail.BackPressed += (sender, args) => detailEmitted = true;
            master.BackPressed += (sender, args) => masterEmitted = true;

            var result = mdp.SendBackButtonPressed();

            Assert.True(masterEmitted);
            Assert.False(detailEmitted);
            Assert.True(result);
        }
Пример #2
0
        public void EmitsCorrectlyWhenPresentedOnBackPressed()
        {
            var detail = new BackButtonPage();
            var Flyout = new BackButtonPage {
                Title = "Flyout"
            };
            var mdp = new FlyoutPage
            {
                Detail            = detail,
                Flyout            = Flyout,
                IsPresented       = true,
                IsPlatformEnabled = true,
            };

            ((IFlyoutPageController)mdp).BackButtonPressed += (sender, args) =>
            {
                args.Handled    = mdp.IsPresented;
                mdp.IsPresented = false;
            };

            var detailEmitted = false;
            var FlyoutEmitted = false;

            detail.BackPressed += (sender, args) => detailEmitted = true;
            Flyout.BackPressed += (sender, args) => FlyoutEmitted = true;

            var result = mdp.SendBackButtonPressed();

            Assert.True(FlyoutEmitted);
            Assert.False(detailEmitted);
            Assert.True(result);
        }
Пример #3
0
        public void SendsBackButtonEventToCurrentPage()
        {
            var current = new BackButtonPage();
            var navPage = new NavigationPage(current);

            var emitted = false;

            current.BackPressed += (sender, args) => emitted = true;

            navPage.SendBackButtonPressed();

            Assert.True(emitted);
        }
Пример #4
0
        public async Task SendsBackButtonEventToCurrentPage(bool useMaui)
        {
            var current = new BackButtonPage();
            var navPage = new TestNavigationPage(useMaui, current);

            var emitted = false;

            current.BackPressed += (sender, args) => emitted = true;

            await navPage.SendBackButtonPressedAsync();

            Assert.True(emitted);
        }
Пример #5
0
        public void DoesNotSendBackEventToNonCurrentPage()
        {
            var current = new BackButtonPage();
            var navPage = new NavigationPage(current);

            navPage.PushAsync(new ContentPage());

            var emitted = false;

            current.BackPressed += (sender, args) => emitted = true;

            navPage.SendBackButtonPressed();

            Assert.False(emitted);
        }
Пример #6
0
        public async Task DoesNotSendBackEventToNonCurrentPage(bool useMaui)
        {
            var current = new BackButtonPage();
            var navPage = new TestNavigationPage(useMaui, current);

            navPage.PushAsync(new ContentPage());

            var emitted = false;

            current.BackPressed += (sender, args) => emitted = true;

            await navPage.SendBackButtonPressedAsync();

            Assert.False(emitted);
        }
Пример #7
0
        public async Task DoesNotNavigatesBackWhenBackButtonPressedIfHandled()
        {
            var root = new BackButtonPage {
                Title = "Root"
            };
            var second = new BackButtonPage()
            {
                Handle = true
            };
            var navPage = new NavigationPage(root);

            await navPage.PushAsync(second);

            navPage.SendBackButtonPressed();

            Assert.AreEqual(second, navPage.CurrentPage);
        }