OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <memory> | 5 #include <memory> |
6 | 6 |
7 #include "gpu/vulkan/tests/native_window.h" | 7 #include "gpu/vulkan/tests/basic_vulkan_test.h" |
8 #include "gpu/vulkan/vulkan_command_buffer.h" | 8 #include "gpu/vulkan/vulkan_command_buffer.h" |
9 #include "gpu/vulkan/vulkan_device_queue.h" | |
10 #include "gpu/vulkan/vulkan_render_pass.h" | 9 #include "gpu/vulkan/vulkan_render_pass.h" |
11 #include "gpu/vulkan/vulkan_surface.h" | 10 #include "gpu/vulkan/vulkan_surface.h" |
12 #include "gpu/vulkan/vulkan_swap_chain.h" | 11 #include "gpu/vulkan/vulkan_swap_chain.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | |
14 #include "ui/gfx/geometry/rect.h" | |
15 | 12 |
16 // This file tests basic vulkan initialization steps. | 13 // This file tests basic vulkan initialization steps. |
17 | 14 |
18 namespace gpu { | 15 namespace gpu { |
19 | 16 |
20 class BasicVulkanTest : public testing::Test { | |
21 public: | |
22 void SetUp() override { | |
23 const gfx::Rect kDefaultBounds(10, 10, 100, 100); | |
24 window_ = CreateNativeWindow(kDefaultBounds); | |
25 device_queue_.Initialize( | |
26 VulkanDeviceQueue::GRAPHICS_QUEUE_FLAG | | |
27 VulkanDeviceQueue::PRESENTATION_SUPPORT_QUEUE_FLAG); | |
28 } | |
29 | |
30 void TearDown() override { | |
31 DestroyNativeWindow(window_); | |
32 window_ = gfx::kNullAcceleratedWidget; | |
33 device_queue_.Destroy(); | |
34 } | |
35 | |
36 gfx::AcceleratedWidget window() const { return window_; } | |
37 VulkanDeviceQueue* GetDeviceQueue() { return &device_queue_; } | |
38 | |
39 private: | |
40 VulkanDeviceQueue device_queue_; | |
41 gfx::AcceleratedWidget window_ = gfx::kNullAcceleratedWidget; | |
42 }; | |
43 | |
44 TEST_F(BasicVulkanTest, BasicVulkanSurface) { | 17 TEST_F(BasicVulkanTest, BasicVulkanSurface) { |
45 std::unique_ptr<VulkanSurface> surface = | 18 std::unique_ptr<VulkanSurface> surface = |
46 VulkanSurface::CreateViewSurface(window()); | 19 VulkanSurface::CreateViewSurface(window()); |
47 EXPECT_TRUE(surface); | 20 EXPECT_TRUE(surface); |
48 EXPECT_TRUE(surface->Initialize(GetDeviceQueue(), | 21 EXPECT_TRUE(surface->Initialize(GetDeviceQueue(), |
49 VulkanSurface::DEFAULT_SURFACE_FORMAT)); | 22 VulkanSurface::DEFAULT_SURFACE_FORMAT)); |
50 surface->Destroy(); | 23 surface->Destroy(); |
51 } | 24 } |
52 | 25 |
53 TEST_F(BasicVulkanTest, EmptyVulkanSwaps) { | 26 TEST_F(BasicVulkanTest, EmptyVulkanSwaps) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 96 |
124 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers()); | 97 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers()); |
125 } | 98 } |
126 | 99 |
127 surface->Finish(); | 100 surface->Finish(); |
128 render_pass.Destroy(); | 101 render_pass.Destroy(); |
129 surface->Destroy(); | 102 surface->Destroy(); |
130 } | 103 } |
131 | 104 |
132 } // namespace gpu | 105 } // namespace gpu |
OLD | NEW |