View Javadoc
1   /*
2    * Copyright 2020-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.hardware;
6   
7   import static org.hamcrest.MatcherAssert.assertThat;
8   import static org.hamcrest.Matchers.greaterThanOrEqualTo;
9   import static org.hamcrest.Matchers.is;
10  import static org.hamcrest.Matchers.notNullValue;
11  
12  import org.junit.jupiter.api.Test;
13  
14  import oshi.SystemInfo;
15  
16  /**
17   * Test GraphicsCard
18   */
19  class GraphicsCardTest {
20  
21      /**
22       * Testing sound cards , each attribute.
23       */
24      @Test
25      void testGraphicsCards() {
26          SystemInfo info = new SystemInfo();
27          for (GraphicsCard graphicsCard : info.getHardware().getGraphicsCards()) {
28              assertThat("Graphics card's name should not be null", graphicsCard.getName(), is(notNullValue()));
29              assertThat("Graphics card's vendor should not be null", graphicsCard.getVendor(), is(notNullValue()));
30              assertThat("Graphics card's VRAM should be at least zero", graphicsCard.getVRam(),
31                      is(greaterThanOrEqualTo(0L)));
32              assertThat("Graphics card's VRAM should be divisible by 1024", graphicsCard.getVRam() % 1024, is(0L));
33              assertThat("Graphics card's id number length should be at least 6", graphicsCard.getDeviceId().length(),
34                      is(greaterThanOrEqualTo(6)));
35              assertThat("Graphics card's version information length should be at least 2",
36                      graphicsCard.getVersionInfo().length(), is(greaterThanOrEqualTo(2)));
37          }
38      }
39  }