public void TestChangeModelDuringLoad(bool hasIntermediate) { TestDrawableModel firstModel = null; TestDrawableModel secondModel = null; TestDrawableModel thirdModel = null; AddStep("setup", () => { createModelBackedDrawable(hasIntermediate); backedDrawable.Model = new TestModel(firstModel = new TestDrawableModel(1).With(d => d.AllowLoad.Set())); }); assertDrawableVisibility(1, () => firstModel); AddStep("set second model", () => backedDrawable.Model = new TestModel(secondModel = new TestDrawableModel(2))); assertIntermediateVisibility(hasIntermediate, () => firstModel); AddStep("set third model", () => backedDrawable.Model = new TestModel(thirdModel = new TestDrawableModel(3))); assertIntermediateVisibility(hasIntermediate, () => firstModel); AddStep("allow second model to load", () => secondModel.AllowLoad.Set()); assertIntermediateVisibility(hasIntermediate, () => firstModel); AddStep("allow third model to load", () => thirdModel.AllowLoad.Set()); assertDrawableVisibility(3, () => thirdModel); }
public void TestSetNullModel(bool withPlaceholder, bool fadeOutImmediately) { TestDrawableModel drawableModel = null; AddStep("setup", () => createModelBackedDrawable(withPlaceholder, fadeOutImmediately)); AddStep("set model", () => { backedDrawable.Model = new TestModel(drawableModel = new TestDrawableModel(1)); drawableModel.AllowLoad.Set(); }); AddUntilStep("model is displayed", () => backedDrawable.DisplayedDrawable == drawableModel); AddStep("set null model", () => backedDrawable.Model = null); if (withPlaceholder) { AddAssert("placeholder displayed", () => backedDrawable.DisplayedDrawable is TestPlaceholder); } else { AddAssert("no drawable displayed", () => backedDrawable.DisplayedDrawable == null); } }
public void TestModelDefaultState() { TestDrawableModel drawableModel = null; AddStep("setup", () => { createModelBackedDrawable(false); backedDrawable.Model = new TestModel(drawableModel = new TestDrawableModel(1).With(d => d.AllowLoad.Set())); }); assertDrawableVisibility(1, () => drawableModel); }
private void addUsageSteps() { TestDrawableModel drawableModel = null; AddStep("load first model", () => backedDrawable.Model = new TestModel(drawableModel = new TestDrawableModel())); AddWaitStep("wait a bit", 5); AddStep("finish load", () => drawableModel.AllowLoad.Set()); AddWaitStep("wait a bit", 5); AddStep("load second model", () => backedDrawable.Model = new TestModel(drawableModel = new TestDrawableModel())); AddWaitStep("wait a bit", 5); AddStep("finish load", () => drawableModel.AllowLoad.Set()); }
public void TestSetNullModel() { TestDrawableModel drawableModel = null; AddStep("setup", () => { createModelBackedDrawable(false, true); backedDrawable.Model = new TestModel(drawableModel = new TestDrawableModel(1).With(d => d.AllowLoad.Set())); }); assertDrawableVisibility(1, () => drawableModel); AddStep("set null model", () => backedDrawable.Model = null); AddUntilStep("null model shown", () => backedDrawable.DisplayedDrawable is TestNullDrawableModel); }
public void TestSequentialDelayedLoad(bool withPlaceholder, bool fadeOutImmediately) { const int model_count = 3; var drawableModels = new List <TestDrawableModel>(model_count); AddStep("setup", () => { drawableModels.Clear(); createModelBackedDrawable(withPlaceholder, fadeOutImmediately); }); for (int i = 0; i < model_count; i++) { int localI = i; AddStep($"set model {i + 1}", () => { var model = new TestDrawableModel(localI + 1); drawableModels.Add(model); backedDrawable.Model = new TestModel(model); }); } // Due to potential left-over threading from elsewhere, we may have to wait for all models to get into a loading state AddUntilStep("all loading", () => drawableModels.TrueForAll(d => d.LoadState == LoadState.Loading)); for (int i = 0; i < model_count - 1; i++) { int localI = i; AddStep($"allow model {i + 1} to load", () => drawableModels[localI].AllowLoad.Set()); AddWaitStep("wait for potential load", 5); if (withPlaceholder) { AddAssert("placeholder displayed", () => backedDrawable.DisplayedDrawable is TestPlaceholder); } else { AddAssert("no model displayed", () => backedDrawable.DisplayedDrawable == null); } AddAssert($"model {i + 1} not loaded", () => !drawableModels[localI].IsLoaded); } AddStep($"allow model {model_count} to load", () => drawableModels[model_count - 1].AllowLoad.Set()); AddUntilStep($"model {model_count} displayed", () => backedDrawable.DisplayedDrawable == drawableModels[model_count - 1]); }
public void TestIntermediaryPlaceholder(bool withPlaceholder, bool fadeOutImmediately) { TestDrawableModel firstModel = null; TestDrawableModel secondModel = null; AddStep("setup", () => createModelBackedDrawable(withPlaceholder, fadeOutImmediately)); AddStep("set first model", () => backedDrawable.Model = new TestModel(firstModel = new TestDrawableModel(1))); if (withPlaceholder) { AddAssert("placeholder is displayed", () => backedDrawable.DisplayedDrawable is TestPlaceholder); } else { AddAssert("nothing displayed", () => backedDrawable.DisplayedDrawable == null); } AddStep("allow first model to load", () => firstModel.AllowLoad.Set()); AddUntilStep("first model displayed", () => backedDrawable.DisplayedDrawable == firstModel); AddStep("set second model", () => backedDrawable.Model = new TestModel(secondModel = new TestDrawableModel(2))); if (fadeOutImmediately) { if (withPlaceholder) { AddAssert("placeholder is displayed", () => backedDrawable.DisplayedDrawable is TestPlaceholder); } else { AddAssert("nothing displayed", () => backedDrawable.DisplayedDrawable == null); } } else { AddAssert("first model still displayed", () => backedDrawable.DisplayedDrawable == firstModel); } AddStep("allow second model to load", () => secondModel.AllowLoad.Set()); AddUntilStep("second model displayed", () => backedDrawable.DisplayedDrawable == secondModel); }
public void TestMultipleLoadDisplaysSinglePlaceholder(bool withPlaceholder, bool fadeOutImmediately) { TestDrawableModel firstModel = null; TestDrawableModel secondModel = null; Drawable placeholder = null; AddStep("setup", () => createModelBackedDrawable(withPlaceholder, fadeOutImmediately)); AddStep("set first model", () => { backedDrawable.Model = new TestModel(firstModel = new TestDrawableModel(1)); placeholder = backedDrawable.DisplayedDrawable; }); AddStep("set second model", () => backedDrawable.Model = new TestModel(secondModel = new TestDrawableModel(2))); AddAssert("first placeholder still displayed", () => backedDrawable.DisplayedDrawable == placeholder); AddStep("allow first model to load", () => firstModel.AllowLoad.Set()); AddAssert("first placeholder still displayed", () => backedDrawable.DisplayedDrawable == placeholder); AddStep("allow second model to load", () => secondModel.AllowLoad.Set()); AddUntilStep("second model displayed", () => backedDrawable.DisplayedDrawable == secondModel); }
public void TestInsideBufferedContainer() { TestDrawableModel drawableModel = null; AddStep("setup", () => { Child = new BufferedContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(200), Child = backedDrawable = new TestModelBackedDrawable { RelativeSizeAxes = Axes.Both, HasIntermediate = false, ShowNullModel = false, Model = new TestModel(drawableModel = new TestDrawableModel(1).With(d => d.AllowLoad.Set())) } }; }); assertDrawableVisibility(1, () => drawableModel); }
public TestModel(TestDrawableModel drawableModel) { DrawableModel = drawableModel; }
public TestModel(TestDrawableModel drawable) { Drawable = drawable; }