THM1176InstrumentManager  1.0
Qt Object abstraction for Metrolab THM1176
IEEE488ResourceManagerTest.h
Go to the documentation of this file.
1 // Copyright (c) 2020 Metrolab Technology S.A., Geneva, Switzerland (www.metrolab.com)
2 // See the included file LICENSE.txt for the licensing conditions.
3 
7 
8 #pragma once
9 
10 #include <gtest/gtest.h>
11 
12 #include "IEEE488InstrumentTest.h"
13 
14 using namespace testing;
15 
16 class IEEE488ResourceManagerTest : public ::testing::Test
17 {
18 protected:
19  static IEEE4888_TEST_RESOURCE_MANAGER_CLASS * pResourceManager;
20 
21  static void SetUpTestCase()
22  {
23  pResourceManager = new IEEE4888_TEST_RESOURCE_MANAGER_CLASS;
24  ASSERT_NE(nullptr, pResourceManager);
25  ASSERT_EQ(true, pResourceManager->Initialize());
26  }
27 
28  static void TearDownTestCase()
29  {
30  delete pResourceManager;
31  pResourceManager = nullptr;
32  }
33 };
34 
35 IEEE4888_TEST_RESOURCE_MANAGER_CLASS * IEEE488ResourceManagerTest::pResourceManager = nullptr;
36 
40 TEST_F(IEEE488ResourceManagerTest, FindResourcesDuringOneMinute)
41 {
42  std::chrono::system_clock::time_point l_EndTime = std::chrono::system_clock::now() + std::chrono::minutes(1);
43  while (std::chrono::system_clock::now() < l_EndTime)
44  {
45  CResourceList l_ResourceList;
46  ASSERT_EQ(true, pResourceManager->FindResources(l_ResourceList, IEEE4888_TEST_RESOURCE_FILTER));
47  std::cout << l_ResourceList.Dump();
48 
49  std::cout << "Status: " << pResourceManager->StatusDescription(pResourceManager->Status()) << std::endl << std::endl;
50 
51  std::this_thread::sleep_for(std::chrono::seconds(1));
52  }
53 }
MTL::Instrument::CResourceList
List of VISA resource names.
Definition: IEEE488InstrumentTypes.h:26
IEEE488ResourceManagerTest
Definition: IEEE488ResourceManagerTest.h:17
IEEE488InstrumentTest.h
Utility functions used to test IEEE488Instrument API.
IEEE488ResourceManagerTest::TearDownTestCase
static void TearDownTestCase()
Definition: IEEE488ResourceManagerTest.h:28
MTL::Instrument::CResourceList::Dump
std::string Dump() const
Dump the VISA resource list into a string.
Definition: IEEE488InstrumentTypes.h:28
TEST_F
TEST_F(IEEE488ResourceManagerTest, FindResourcesDuringOneMinute)
Test FindResources by calling it repeatedly and dumping the output. Note: to see the output in Qt Cre...
Definition: IEEE488ResourceManagerTest.h:40
IEEE488ResourceManagerTest::SetUpTestCase
static void SetUpTestCase()
Definition: IEEE488ResourceManagerTest.h:21
IEEE488ResourceManagerTest::pResourceManager
static IEEE4888_TEST_RESOURCE_MANAGER_CLASS * pResourceManager
Definition: IEEE488ResourceManagerTest.h:19