diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 19:14:54 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 19:14:54 +0000 |
commit | cd0159184afb59be5d17c78289ecdd9845575606 (patch) | |
tree | de6968d7eb377ef5d151553595e1bca216bd3207 /chromeos | |
parent | 717df345aba59f0b3d91fa2a76fdf9e11df46b56 (diff) | |
download | chromium_src-cd0159184afb59be5d17c78289ecdd9845575606.zip chromium_src-cd0159184afb59be5d17c78289ecdd9845575606.tar.gz chromium_src-cd0159184afb59be5d17c78289ecdd9845575606.tar.bz2 |
Only send test sms messages on a switch.
Use Shell singleton system/web_notification trays in unittests.
Ash notifications have two problems with unit tests:
1. SmsWatcher only expects to be initialized once. The unit tests were creating one instance of SystemTray in the Shell instance created in AshTestBase, and a second was getting created in SystemTrayTest. Both contain a TraySms that initializes SmsWatcher. I expect there could be other side effects of having two system trays, so using the one in Shell in the unit tests seemed best.
2. The Sms stub was always generating test notifications when the default view was shown, which made the unit test behavior difficult to predict. The solution is to put these test messages on a flag.
BUG=none
TEST=aura_shell_unittests pass with --ash-notify
Review URL: https://chromiumcodereview.appspot.com/10553008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/chromeos_switches.cc | 3 | ||||
-rw-r--r-- | chromeos/chromeos_switches.h | 1 | ||||
-rw-r--r-- | chromeos/dbus/gsm_sms_client.cc | 5 | ||||
-rw-r--r-- | chromeos/dbus/sms_client.cc | 6 |
4 files changed, 15 insertions, 0 deletions
diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc index 2c1e3ad..2ade84b 100644 --- a/chromeos/chromeos_switches.cc +++ b/chromeos/chromeos_switches.cc @@ -10,5 +10,8 @@ namespace switches { // Forces the stub implementation of dbus clients. const char kDbusStub[] = "dbus-stub"; +// Sends test messages on first call to RequestUpdate (stub only). +const char kSmsTestMessages[] = "sms-test-messages"; + } // namespace switches } // namespace chromeos diff --git a/chromeos/chromeos_switches.h b/chromeos/chromeos_switches.h index 5b33dea..5eeb21b 100644 --- a/chromeos/chromeos_switches.h +++ b/chromeos/chromeos_switches.h @@ -22,6 +22,7 @@ namespace switches { // Please keep alphabetized. CHROMEOS_EXPORT extern const char kDbusStub[]; +CHROMEOS_EXPORT extern const char kSmsTestMessages[]; } // namespace switches } // namespace chromeos diff --git a/chromeos/dbus/gsm_sms_client.cc b/chromeos/dbus/gsm_sms_client.cc index 2836605..149d743 100644 --- a/chromeos/dbus/gsm_sms_client.cc +++ b/chromeos/dbus/gsm_sms_client.cc @@ -8,12 +8,14 @@ #include <vector> #include "base/bind.h" +#include "base/command_line.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/message_loop.h" #include "base/stringprintf.h" #include "base/stl_util.h" #include "base/values.h" +#include "chromeos/chromeos_switches.h" #include "dbus/bus.h" #include "dbus/message.h" #include "dbus/object_proxy.h" @@ -295,6 +297,9 @@ class GsmSMSClientStubImpl : public GsmSMSClient { // GsmSMSClient override. virtual void RequestUpdate(const std::string& service_name, const dbus::ObjectPath& object_path) { + if (!CommandLine::ForCurrentProcess()->HasSwitch( + chromeos::switches::kSmsTestMessages)) + return; if (test_index_ >= 0) return; test_index_ = 0; diff --git a/chromeos/dbus/sms_client.cc b/chromeos/dbus/sms_client.cc index 72df74d..ee9fe10 100644 --- a/chromeos/dbus/sms_client.cc +++ b/chromeos/dbus/sms_client.cc @@ -7,12 +7,14 @@ #include <utility> #include "base/bind.h" +#include "base/command_line.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/message_loop.h" #include "base/stringprintf.h" #include "base/stl_util.h" #include "base/values.h" +#include "chromeos/chromeos_switches.h" #include "dbus/bus.h" #include "dbus/message.h" #include "dbus/object_proxy.h" @@ -82,6 +84,10 @@ class SMSClientStubImpl : public SMSClient { virtual void GetAll(const std::string& service_name, const dbus::ObjectPath& object_path, const GetAllCallback& callback) OVERRIDE { + if (!CommandLine::ForCurrentProcess()->HasSwitch( + chromeos::switches::kSmsTestMessages)) + return; + // Ownership passed to callback base::DictionaryValue *sms = new base::DictionaryValue(); sms->SetString("Number", "000-000-0000"); |