IVGCVSW-3030 Add unit testing for the Optimization API

 * Added OptimizeSubgraphViewTests file covering a number of
   use cases for the Optimization API
 * Fixed a bug in the sub-graph selector algorithm that skipped the
   first layer in a sub-graph if it wasn't an input layer
 * Changed the graph splitting logic to make use of maps instead of
   unordered_maps to keep the split sub-graphs in consistent order
   between executions
 * Added more common unit test utils
 * Minor fixes to comply to the include file conventions

Change-Id: Iad464eaedd004109e5ef41aa487cea3ad86177d3
Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
diff --git a/src/backends/backendsCommon/test/CommonTestUtils.cpp b/src/backends/backendsCommon/test/CommonTestUtils.cpp
new file mode 100644
index 0000000..7685626
--- /dev/null
+++ b/src/backends/backendsCommon/test/CommonTestUtils.cpp
@@ -0,0 +1,59 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "CommonTestUtils.hpp"
+
+#include <backendsCommon/IBackendInternal.hpp>
+
+using namespace armnn;
+
+void Connect(armnn::IConnectableLayer* from, armnn::IConnectableLayer* to, const armnn::TensorInfo& tensorInfo,
+             unsigned int fromIndex, unsigned int toIndex)
+{
+    from->GetOutputSlot(fromIndex).Connect(to->GetInputSlot(toIndex));
+    from->GetOutputSlot(fromIndex).SetTensorInfo(tensorInfo);
+}
+
+SubgraphView::InputSlots CreateInputsFrom(const std::vector<Layer*>& layers)
+{
+    SubgraphView::InputSlots result;
+    for (auto&& layer : layers)
+    {
+        for (auto&& it = layer->BeginInputSlots(); it != layer->EndInputSlots(); ++it)
+        {
+            result.push_back(&(*it));
+        }
+    }
+    return result;
+}
+
+SubgraphView::OutputSlots CreateOutputsFrom(const std::vector<Layer*>& layers)
+{
+    SubgraphView::OutputSlots result;
+    for (auto && layer : layers)
+    {
+        for (auto&& it = layer->BeginOutputSlots(); it != layer->EndOutputSlots(); ++it)
+        {
+            result.push_back(&(*it));
+        }
+    }
+    return result;
+}
+
+SubgraphView::SubgraphViewPtr CreateSubgraphViewFrom(SubgraphView::InputSlots&& inputs,
+                                                     SubgraphView::OutputSlots&& outputs,
+                                                     SubgraphView::Layers&& layers)
+{
+    return std::make_unique<SubgraphView>(std::move(inputs), std::move(outputs), std::move(layers));
+}
+
+armnn::IBackendInternalUniquePtr CreateBackendObject(const armnn::BackendId& backendId)
+{
+    auto& backendRegistry = BackendRegistryInstance();
+    auto  backendFactory  = backendRegistry.GetFactory(backendId);
+    auto  backendObjPtr   = backendFactory();
+
+    return backendObjPtr;
+}