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

Side by Side Diff: chrome/browser/metrics/desktop_engagement/chrome_visibility_observer_browsertest.cc

Issue 2142983002: Add desktop engagement metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments and fix mac bot 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 "chrome/browser/metrics/desktop_engagement/chrome_visibility_observer.h "
6
7 #include "base/memory/singleton.h"
8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_list.h"
11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/notification_service.h"
14 #include "content/public/test/test_utils.h"
15
16 // Mock class for |ChromeVisibilityObserver| for testing.
17 class MockChromeVisibilityObserver : public metrics::ChromeVisibilityObserver {
18 public:
19 MockChromeVisibilityObserver() : is_active_(false) {}
20
21 bool IsActive() { return is_active_; }
Alexei Svitkine (slow) 2016/07/26 22:00:40 bool is_active() const Same for other accessors i
gayane -on leave until 09-2017 2016/07/27 21:10:25 Done.
22
23 private:
24 void SendVisibilityChangeEvent(bool active) override { is_active_ = active; }
25
26 bool is_active_;
Alexei Svitkine (slow) 2016/07/26 22:00:40 Add an empty line below this.
gayane -on leave until 09-2017 2016/07/27 21:10:24 Done.
27 DISALLOW_COPY_AND_ASSIGN(MockChromeVisibilityObserver);
28 };
29
30 class ChromeVisibilityObserverBrowserTest : public InProcessBrowserTest {};
31
32 IN_PROC_BROWSER_TEST_F(ChromeVisibilityObserverBrowserTest, VisibilityTest) {
33 MockChromeVisibilityObserver observer;
34
35 EXPECT_FALSE(observer.IsActive());
36 Browser* new_browser = CreateBrowser(browser()->profile());
37 EXPECT_TRUE(observer.IsActive());
38
39 Browser* incognito_browser = CreateIncognitoBrowser();
40 EXPECT_TRUE(observer.IsActive());
41
42 CloseBrowserSynchronously(incognito_browser);
43 EXPECT_TRUE(observer.IsActive());
44
45 CloseBrowserSynchronously(new_browser);
46 CloseBrowserSynchronously(browser());
47 EXPECT_FALSE(observer.IsActive());
48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698