Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1481)

Side by Side Diff: blimp/client/core/contents/blimp_contents_observer_unittest.cc

Issue 2201433002: Migrate TabControlFeature from 0.5 to 0.6 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: some more compile error fix Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/client/public/contents/blimp_contents_observer.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "blimp/client/core/contents/blimp_contents_impl.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace {
13 const int kDummyTabId = 0;
14 }
15
16 namespace blimp {
17 namespace client {
18
19 namespace {
20
21 class BlimpContentsObserverTest : public BlimpContentsObserver {
22 public:
23 explicit BlimpContentsObserverTest(BlimpContents* blimp_contents)
24 : BlimpContentsObserver(blimp_contents) {}
25
26 MOCK_METHOD0(OnContentsDestroyed, void());
27
28 private:
29 DISALLOW_COPY_AND_ASSIGN(BlimpContentsObserverTest);
30 };
31
32 TEST(BlimpContentsObserverUnittests, ObserverDies) {
33 BlimpContentsImpl contents(kDummyTabId);
34
35 std::unique_ptr<BlimpContentsObserver> observer =
36 base::MakeUnique<BlimpContentsObserverTest>(&contents);
37 BlimpContentsObserver* observer_ptr = observer.get();
38 EXPECT_TRUE(contents.HasObserver(observer_ptr));
39 observer.reset();
40
41 EXPECT_FALSE(contents.HasObserver(observer_ptr));
42 }
43
44 TEST(BlimpContentsObserverUnittests, ContentsDies) {
45 std::unique_ptr<BlimpContentsObserverTest> observer;
46
47 std::unique_ptr<BlimpContentsImpl> contents =
48 base::MakeUnique<BlimpContentsImpl>(kDummyTabId);
49 observer.reset(new BlimpContentsObserverTest(contents.get()));
50 EXPECT_CALL(*observer, OnContentsDestroyed()).Times(1);
51 EXPECT_EQ(observer->blimp_contents(), contents.get());
52 contents.reset();
53
54 EXPECT_EQ(observer->blimp_contents(), nullptr);
55 }
56
57 } // namespace
58
59 } // namespace client
60 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/contents/blimp_contents_manager_unittest.cc ('k') | blimp/client/core/contents/tab_control_feature.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698