File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ #include  < iostream> 
2+ #include  < thread> 
3+ #include  < chrono> 
4+ 
5+ #include  " camera/mock.hpp" 
6+ 
7+ int  main () {
8+     MockCamera camera;
9+     int  init = camera.getImageCount ();
10+ 
11+     camera.startTakingPictures (std::chrono::milliseconds (DUMMY_TIMEOUT));
12+     std::this_thread::sleep_for (std::chrono::milliseconds (3000 ));
13+     camera.stopTakingPictures ();
14+ 
15+     int  post  = camera.getImageCount ();
16+     std::cout << " # of images taken:"   << post  << std::endl;
17+ 
18+     return  (post  > init) ? 0  : 2 ; 
19+ }
20+ 
Original file line number Diff line number Diff line change 1+ #include  < gtest/gtest.h> 
2+ #include  < chrono> 
3+ 
4+ #include  " camera/mock.hpp" 
5+ 
6+ TEST (MockCameraTest, FilePathValid) {
7+     MockCamera camera;
8+ 
9+     std::vector<std::filesystem::directory_entry> entries;
10+     for  (auto & entry : std::filesystem::directory_iterator (images_dir)) {
11+         entries.push_back (entry);
12+     }
13+ 
14+     //  Expect set filepath has images
15+     EXPECT_FALSE (entries.empty ());
16+ }
17+ 
18+ TEST (MockCameraTest, TestTakingPicture) {
19+     MockCamera camera;
20+ 
21+     std::optional<ImageData> img = camera.takePicture (std::chrono::milliseconds (DUMMY_TIMEOUT));
22+     EXPECT_TRUE (img.has_value ());
23+ }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments