Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Unified Diff: gpu/vulkan/tests/vulkan_test.cc

Issue 1776453003: Added initial implementation of Vulkan Render Passes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn_vulkan
Patch Set: Fix SwapBuffers() present layout, test in unittests instead of injections Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/vulkan/tests/vulkan_test.cc
diff --git a/gpu/vulkan/tests/vulkan_test.cc b/gpu/vulkan/tests/vulkan_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a3077de7206f4a276fb2140b9c8b92da9fc94c6a
--- /dev/null
+++ b/gpu/vulkan/tests/vulkan_test.cc
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/vulkan/tests/native_window.h"
+#include "gpu/vulkan/vulkan_surface.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/geometry/rect.h"
+
+// This file tests basic vulkan initialization steps.
+namespace gpu {
+
+class BasicVulkanTest : public testing::Test {
+ public:
+ void SetUp() override {
+ const gfx::Rect kDefaultBounds(10, 10, 100, 100);
+ window_ = CreateNativeWindow(kDefaultBounds);
+ }
+
+ void TearDown() override {
+ DestroyNativeWindow(window_);
+ window_ = gfx::kNullAcceleratedWidget;
+ }
+
+ gfx::AcceleratedWidget window() const { return window_; }
+
+ private:
+ gfx::AcceleratedWidget window_ = gfx::kNullAcceleratedWidget;
+};
+
+TEST_F(BasicVulkanTest, BasicVulkanSurface) {
+ scoped_ptr<VulkanSurface> surface =
+ VulkanSurface::CreateViewSurface(window());
+ EXPECT_TRUE(surface);
+ EXPECT_TRUE(surface->Initialize(VulkanSurface::SURFACE_GBRA8888));
+ surface->Destroy();
+}
+
+TEST_F(BasicVulkanTest, EmptyVulkanSwaps) {
+ scoped_ptr<VulkanSurface> surface =
+ VulkanSurface::CreateViewSurface(window());
+ EXPECT_TRUE(surface);
+ EXPECT_TRUE(surface->Initialize(VulkanSurface::SURFACE_GBRA8888));
+
+ // First swap is a special case, call it first to get better errors.
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers());
+
+ // Also make sure we can swap multiple times.
+ for (int i = 0; i < 10; ++i) {
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers());
+ }
+
+ surface->Destroy();
+}
+
+} // namespace gpu

Powered by Google App Engine
This is Rietveld 408576698