Flutter Engine
embedder_test.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "flutter/shell/platform/embedder/tests/embedder_test.h"
6 #include "flutter/shell/platform/embedder/tests/embedder_test_context_software.h"
7 
8 #ifdef SHELL_ENABLE_GL
9 #include "flutter/shell/platform/embedder/tests/embedder_test_context_gl.h"
10 #endif
11 
12 #ifdef SHELL_ENABLE_METAL
13 #include "flutter/shell/platform/embedder/tests/embedder_test_context_metal.h"
14 #endif
15 
16 namespace flutter {
17 namespace testing {
18 
19 EmbedderTest::EmbedderTest() = default;
20 
22  return GetFixturesPath();
23 }
24 
27  // Setup the embedder context lazily instead of in the constructor because we
28  // don't to do all the work if the test won't end up using context.
29  if (!embedder_contexts_[type]) {
30  switch (type) {
32  embedder_contexts_[type] =
33  std::make_unique<EmbedderTestContextSoftware>(
35  break;
36 #ifdef SHELL_ENABLE_GL
38  embedder_contexts_[type] =
39  std::make_unique<EmbedderTestContextGL>(GetFixturesDirectory());
40  break;
41 #endif
42 #ifdef SHELL_ENABLE_METAL
44  embedder_contexts_[type] =
45  std::make_unique<EmbedderTestContextMetal>(GetFixturesDirectory());
46  break;
47 #endif
48  default:
49  FML_DCHECK(false) << "Invalid context type specified.";
50  break;
51  }
52  }
53 
54  return *embedder_contexts_[type];
55 }
56 
57 } // namespace testing
58 } // namespace flutter
std::string GetFixturesDirectory() const
KeyCallType type
#define FML_DCHECK(condition)
Definition: logging.h:86
const char * GetFixturesPath()
Returns the directory containing the test fixture for the target if this target has fixtures configur...
EmbedderTestContext & GetEmbedderContext(EmbedderTestContextType type)