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,
                Platform          = new UnitPlatform()
            };

            ((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 SendsBackEventToPresentedMasterFirst()
        {
            var detail = new BackButtonPage()
            {
                Handle = true
            };
            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);
        }
示例#4
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);
        }
示例#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 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);
        }
示例#7
0
		public async void 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);
		}
示例#8
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);
		}
示例#9
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);
		}
		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,
				Platform = new UnitPlatform ()
			};

			((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);
		}