OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 bool need_to_log_status() { return need_to_log_status_; } | 65 bool need_to_log_status() { return need_to_log_status_; } |
66 | 66 |
67 void Prepare(base::Closure quit_closure) { | 67 void Prepare(base::Closure quit_closure) { |
68 quit_closure_ = quit_closure; | 68 quit_closure_ = quit_closure; |
69 } | 69 } |
70 | 70 |
71 protected: | 71 protected: |
72 // All calls to RequestAppBanner should terminate in one of Stop() (not | 72 // All calls to RequestAppBanner should terminate in one of Stop() (not |
73 // showing banner), UpdateState(State::PENDING_ENGAGEMENT) (waiting for | 73 // showing banner), UpdateState(State::PENDING_ENGAGEMENT) (waiting for |
74 // sufficient engagement), or ShowBanner(). Override these methods to capture | 74 // sufficient engagement), or ShowBannerUI(). Override these methods to |
75 // test status. | 75 // capture test status. |
76 void Stop() override { | 76 void Stop() override { |
77 AppBannerManager::Stop(); | 77 AppBannerManager::Stop(); |
78 ASSERT_FALSE(will_show_.get()); | 78 ASSERT_FALSE(will_show_.get()); |
79 will_show_.reset(new bool(false)); | 79 will_show_.reset(new bool(false)); |
80 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_); | 80 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_); |
81 } | 81 } |
82 | 82 |
83 void ShowBanner() override { | 83 void ShowBannerUI() override { |
84 // Fake the call to ReportStatus here - this is usually called in | 84 // Fake the call to ReportStatus here - this is usually called in |
85 // platform-specific code which is not exposed here. | 85 // platform-specific code which is not exposed here. |
86 ReportStatus(nullptr, SHOWING_WEB_APP_BANNER); | 86 ReportStatus(nullptr, SHOWING_WEB_APP_BANNER); |
87 RecordDidShowBanner("AppBanner.WebApp.Shown"); | 87 RecordDidShowBanner("AppBanner.WebApp.Shown"); |
88 | 88 |
89 ASSERT_FALSE(will_show_.get()); | 89 ASSERT_FALSE(will_show_.get()); |
90 will_show_.reset(new bool(true)); | 90 will_show_.reset(new bool(true)); |
91 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_); | 91 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_); |
92 } | 92 } |
93 | 93 |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 EXPECT_FALSE(manager->will_show()); | 524 EXPECT_FALSE(manager->will_show()); |
525 EXPECT_FALSE(manager->is_active()); | 525 EXPECT_FALSE(manager->is_active()); |
526 EXPECT_FALSE(manager->need_to_log_status()); | 526 EXPECT_FALSE(manager->need_to_log_status()); |
527 | 527 |
528 histograms.ExpectTotalCount(banners::kMinutesHistogram, 0); | 528 histograms.ExpectTotalCount(banners::kMinutesHistogram, 0); |
529 histograms.ExpectUniqueSample(banners::kInstallableStatusCodeHistogram, | 529 histograms.ExpectUniqueSample(banners::kInstallableStatusCodeHistogram, |
530 INSUFFICIENT_ENGAGEMENT, 1); | 530 INSUFFICIENT_ENGAGEMENT, 1); |
531 } | 531 } |
532 | 532 |
533 } // namespace banners | 533 } // namespace banners |
OLD | NEW |