Recently we are working on unit testing on our ArcGIS Pro plug-in/add-in application. We are referring the Esri's demo method, (https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Regression-Testing). We have a problem getting the LayoutView.
We can load the project file (.aprx) using the following code:
Project project = Project.OpenAsync(@C:\Users\Administrator\Documents\files\test.aprx).Result;
QueuedTask.Run(() =>
{
_map = project.GetItems<MapProjectItem>().Where(x => x.Name.Equals("Map")).FirstOrDefault().GetMap();
_layers = _map.GetLayersAsFlattenedList();
_layoutProjItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout"));
_layout = _layoutProjItem.GetLayout(); //Worker thread
}).Wait();
But we cannot get LayoutView. For example,
PaneCollection panes = ProApp.Panes;
ILayoutPane layoutPane = panes.FindLayoutPanes(_layout).FirstOrDefault();
layoutPane.LayoutView always returns null.
While We know in ArcGIS Desktop, like 10.*, we can get/initialize everything for example,
Get Mxd file (location of the mxd file)
Get MapDocument
Get PageLayout
Set pageLayout as ActiveView.
My Question is , in unit test, ArcGIS Pro can get LayoutView ? How to get the LayoutView in the Unit test.
thanks
Eric