SF: Break out NativeWindowSurface
I should perhaps have done this originally.
Separating it out like this is better for the upcoming factory change.
Test: atest libsurfaceflinger_unittest
Bug: None
Change-Id: Ia0d87c55cab9b315886eba6320b5e345632e4231
diff --git a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
index cc46043..b474e42 100644
--- a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
@@ -125,7 +125,7 @@
// These mocks are created only when expected to be created via a factory.
sp<mock::GraphicBufferConsumer> mConsumer;
sp<mock::GraphicBufferProducer> mProducer;
- mock::NativeWindowSurface* mNativeWindowSurface = nullptr;
+ surfaceflinger::mock::NativeWindowSurface* mNativeWindowSurface = nullptr;
sp<mock::NativeWindow> mNativeWindow;
renderengine::mock::Surface* mRenderSurface = nullptr;
};
@@ -195,11 +195,12 @@
// This setup is only expected once per test.
ASSERT_TRUE(mNativeWindowSurface == nullptr);
- mNativeWindowSurface = new mock::NativeWindowSurface();
+ mNativeWindowSurface = new surfaceflinger::mock::NativeWindowSurface();
mNativeWindow = new mock::NativeWindow();
- mFlinger.setCreateNativeWindowSurface(
- [this](auto) { return std::unique_ptr<NativeWindowSurface>(mNativeWindowSurface); });
+ mFlinger.setCreateNativeWindowSurface([this](auto) {
+ return std::unique_ptr<surfaceflinger::NativeWindowSurface>(mNativeWindowSurface);
+ });
}
bool DisplayTransactionTest::hasHwcDisplay(hwc2_display_t displayId) {
diff --git a/services/surfaceflinger/tests/unittests/mock/MockNativeWindowSurface.cpp b/services/surfaceflinger/tests/unittests/mock/MockNativeWindowSurface.cpp
index 25ff39b..9cc6d38 100644
--- a/services/surfaceflinger/tests/unittests/mock/MockNativeWindowSurface.cpp
+++ b/services/surfaceflinger/tests/unittests/mock/MockNativeWindowSurface.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 The Android Open Source Project
- *
+ * Copyright 2018 The Android Open Source Project
+
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -16,12 +16,10 @@
#include "mock/MockNativeWindowSurface.h"
-namespace android {
-namespace mock {
+namespace android::surfaceflinger::mock {
// Explicit default instantiation is recommended.
NativeWindowSurface::NativeWindowSurface() = default;
NativeWindowSurface::~NativeWindowSurface() = default;
-} // namespace mock
-} // namespace android
+} // namespace android::surfaceflinger::mock
diff --git a/services/surfaceflinger/tests/unittests/mock/MockNativeWindowSurface.h b/services/surfaceflinger/tests/unittests/mock/MockNativeWindowSurface.h
index 88d1a9f..7bc1151 100644
--- a/services/surfaceflinger/tests/unittests/mock/MockNativeWindowSurface.h
+++ b/services/surfaceflinger/tests/unittests/mock/MockNativeWindowSurface.h
@@ -20,19 +20,17 @@
#include <system/window.h> // for ANativeWindow
-#include "SurfaceFlinger.h" // for base NativeWindowSurface
+#include "NativeWindowSurface.h"
-namespace android {
-namespace mock {
+namespace android::surfaceflinger::mock {
-class NativeWindowSurface : public android::NativeWindowSurface {
+class NativeWindowSurface : public surfaceflinger::NativeWindowSurface {
public:
NativeWindowSurface();
- ~NativeWindowSurface();
+ ~NativeWindowSurface() override;
MOCK_CONST_METHOD0(getNativeWindow, sp<ANativeWindow>());
MOCK_METHOD0(preallocateBuffers, void());
};
-} // namespace mock
-} // namespace android
+} // namespace android::surfaceflinger::mock