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

Side by Side Diff: chrome/browser/extensions/api/notifications/notifications_apitest.cc

Issue 666153002: Standardize usage of virtual/override/final in chrome/browser/extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/strings/string_number_conversions.h" 5 #include "base/strings/string_number_conversions.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/extensions/api/notifications/notifications_api.h" 9 #include "chrome/browser/extensions/api/notifications/notifications_api.h"
10 #include "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
(...skipping 22 matching lines...) Expand all
33 // A class that waits for a |chrome.test.sendMessage| call, ignores the message, 33 // A class that waits for a |chrome.test.sendMessage| call, ignores the message,
34 // and writes down the user gesture status of the message. 34 // and writes down the user gesture status of the message.
35 class UserGestureCatcher : public content::NotificationObserver { 35 class UserGestureCatcher : public content::NotificationObserver {
36 public: 36 public:
37 UserGestureCatcher() : waiting_(false) { 37 UserGestureCatcher() : waiting_(false) {
38 registrar_.Add(this, 38 registrar_.Add(this,
39 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE, 39 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE,
40 content::NotificationService::AllSources()); 40 content::NotificationService::AllSources());
41 } 41 }
42 42
43 virtual ~UserGestureCatcher() {} 43 ~UserGestureCatcher() override {}
44 44
45 bool GetNextResult() { 45 bool GetNextResult() {
46 if (results_.empty()) { 46 if (results_.empty()) {
47 waiting_ = true; 47 waiting_ = true;
48 content::RunMessageLoop(); 48 content::RunMessageLoop();
49 waiting_ = false; 49 waiting_ = false;
50 } 50 }
51 51
52 if (!results_.empty()) { 52 if (!results_.empty()) {
53 bool ret = results_.front(); 53 bool ret = results_.front();
54 results_.pop_front(); 54 results_.pop_front();
55 return ret; 55 return ret;
56 } 56 }
57 NOTREACHED(); 57 NOTREACHED();
58 return false; 58 return false;
59 } 59 }
60 60
61 private: 61 private:
62 virtual void Observe(int type, 62 void Observe(int type,
63 const content::NotificationSource& source, 63 const content::NotificationSource& source,
64 const content::NotificationDetails& details) override { 64 const content::NotificationDetails& details) override {
65 results_.push_back( 65 results_.push_back(
66 static_cast<content::Source<extensions::TestSendMessageFunction> >( 66 static_cast<content::Source<extensions::TestSendMessageFunction> >(
67 source) 67 source)
68 .ptr() 68 .ptr()
69 ->user_gesture()); 69 ->user_gesture());
70 if (waiting_) 70 if (waiting_)
71 base::MessageLoopForUI::current()->Quit(); 71 base::MessageLoopForUI::current()->Quit();
72 } 72 }
73 73
74 content::NotificationRegistrar registrar_; 74 content::NotificationRegistrar registrar_;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 notification->ButtonClick(0); 280 notification->ButtonClick(0);
281 EXPECT_TRUE(catcher.GetNextResult()); 281 EXPECT_TRUE(catcher.GetNextResult());
282 notification->Click(); 282 notification->Click();
283 EXPECT_TRUE(catcher.GetNextResult()); 283 EXPECT_TRUE(catcher.GetNextResult());
284 notification->Close(true); 284 notification->Close(true);
285 EXPECT_TRUE(catcher.GetNextResult()); 285 EXPECT_TRUE(catcher.GetNextResult());
286 notification->Close(false); 286 notification->Close(false);
287 EXPECT_FALSE(catcher.GetNextResult()); 287 EXPECT_FALSE(catcher.GetNextResult());
288 } 288 }
289 } 289 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/notifications/notifications_api.cc ('k') | chrome/browser/extensions/api/omnibox/omnibox_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698