~ubuntu-branches/ubuntu/vivid/mir/vivid

« back to all changes in this revision

Viewing changes to tests/unit-tests/graphics/android/test_sync_fence.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-08-11 19:52:06 UTC
  • mto: This revision was merged to the branch mainline in revision 77.
  • Revision ID: package-import@ubuntu.com-20140811195206-05ee991qbzvdbmel
Tags: upstream-0.6.0+14.10.20140811
ImportĀ upstreamĀ versionĀ 0.6.0+14.10.20140811

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    virtual void SetUp()
45
45
    {
46
46
        mock_fops = std::make_shared<testing::NiceMock<MockFileOps>>();
 
47
        dummy_fd_value = 3;
47
48
    }
48
49
 
49
 
    int dummy_fd = 3;
50
 
    int invalid_fd = -1;
 
50
    int dummy_fd_value{3};
 
51
    int invalid_fd_value{-1};
 
52
    mir::Fd dummy_fd{std::move(dummy_fd_value)};
 
53
    mir::Fd invalid_fd{std::move(invalid_fd_value)};
51
54
    std::shared_ptr<MockFileOps> mock_fops;
52
55
};
53
56
 
70
73
 
71
74
TEST_F(SyncSwTest, sync_wait)
72
75
{
73
 
    EXPECT_CALL(*mock_fops, ioctl(dummy_fd, SYNC_IOC_WAIT, TimeoutMatches(-1)))
 
76
    EXPECT_CALL(*mock_fops, ioctl(dummy_fd_value, SYNC_IOC_WAIT, TimeoutMatches(-1)))
74
77
        .Times(1);
75
 
    mga::SyncFence fence1(mock_fops, dummy_fd);
 
78
    mga::SyncFence fence1(mock_fops, std::move(dummy_fd));
76
79
    fence1.wait();
77
80
 
78
81
    //will not call ioctl
79
 
    mga::SyncFence fence2(mock_fops, invalid_fd);
 
82
    mga::SyncFence fence2(mock_fops, std::move(invalid_fd));
80
83
    fence2.wait();
81
84
}
82
85
 
83
 
 
84
86
namespace
85
87
{
86
88
struct IoctlSetter
107
109
 
108
110
    struct sync_merge_data expected_data_in { dummy_fd2, "name", 0 };
109
111
 
110
 
    EXPECT_CALL(*mock_fops, ioctl(dummy_fd, static_cast<int>(SYNC_IOC_MERGE), MergeMatches(expected_data_in)))
 
112
    EXPECT_CALL(*mock_fops, ioctl(dummy_fd_value, static_cast<int>(SYNC_IOC_MERGE), MergeMatches(expected_data_in)))
111
113
        .Times(1)
112
114
        .WillOnce(Invoke(&setter, &IoctlSetter::merge_setter));
113
115
 
114
 
    mga::SyncFence fence1(mock_fops, dummy_fd);
115
 
 
 
116
    mga::SyncFence fence1(mock_fops, std::move(dummy_fd));
116
117
    fence1.merge_with(dummy_fd2);
117
118
}
118
119
 
119
120
TEST_F(SyncSwTest, sync_merge_with_invalid_fd)
120
121
{
121
122
    using namespace testing;
122
 
    EXPECT_CALL(*mock_fops, ioctl(dummy_fd, static_cast<int>(SYNC_IOC_MERGE), _))
 
123
    EXPECT_CALL(*mock_fops, ioctl(dummy_fd_value, static_cast<int>(SYNC_IOC_MERGE), _))
123
124
        .Times(0);
124
125
 
125
 
    mga::SyncFence fence1(mock_fops, invalid_fd);
126
 
 
127
 
    fence1.merge_with(dummy_fd);
 
126
    mga::SyncFence fence1(mock_fops, std::move(dummy_fd));
 
127
    fence1.merge_with(invalid_fd_value);
128
128
}
129
129
 
130
130
TEST_F(SyncSwTest, copy_dups_fd)
131
131
{
132
132
    using namespace testing;
133
 
    int fd2 = dummy_fd + 1;
134
 
    EXPECT_CALL(*mock_fops, dup(dummy_fd))
 
133
    int fd2 = dummy_fd_value + 1;
 
134
    EXPECT_CALL(*mock_fops, dup(dummy_fd_value))
135
135
        .Times(1)
136
136
        .WillOnce(Return(fd2));;
137
137
 
138
 
    mga::SyncFence fence(mock_fops, dummy_fd);
 
138
    mga::SyncFence fence(mock_fops, std::move(dummy_fd));
139
139
 
140
140
    EXPECT_EQ(fd2, fence.copy_native_handle());
141
141
}