title: GMOCK EXPECT_CALL on unique_ptr
body: <p>One of the benefits of dependency injection is ease of testing, as mocked classes can be injected. Clazz takes raw pointer for that purpose and moves it to unique pointer, to signal that it owns InjectedObj object:</p>
  
  <pre><code>Clazz::Clazz(InjectedObj *injectedObj)  : injectedObjPtr(injectedObj) { }
  </code></pre>
  
  <p>where <code>injectedObjPtr</code> is member:</p>
  
  <pre><code>std::unique_ptr&lt;InjectedObj&gt; injectedObjPtr;
  </code></pre>
  
  <p>doSth method calls executeSth by calling smart pointer:</p>
  
  <pre><code>//doSth method
  int CLazz::doSth() {
  return injectedObjPtr-&gt;executeSth();
  }
  </code></pre>
  
  <p>I would like to test Clazz by setting some expectations on injected object,
  so my test looks similar to this:</p>
  
  <pre><code>TEST_F(testFixture, exeuteTest)
  {
    //before
    InjectedObj* injectedObj = new InjectedObj();
    EXPECT_CALL(*injectedObj, executeSth())
      .Times(1)
      .WillOnce(Return(100));
  
    //when
    Clazz clazz(injectedObj);
  
    //then
    ASSERT_DOUBLE_EQ(clazz-&gt;doSth(), 100);
  }
  </code></pre>
  
  <p>So in this simplified scenario <code>clazz-&gt;doSth()</code> is calling <code>injectedObj-&gt;executeSth</code> which should return 100, but it behaves like I would never set my expectation and always gets 0. Obviously if I will call my mocked object without smart pointer: <code>injectedObj-&gt;executeSth</code> it returns 100, but not when calling it using unique_ptr. Is there any way of telling gmock to set correct expectations when mocked object is managed by smart pointer? Thanks</p>