| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/ui/idle_app_name_notification_view.h" | 5 #include "chrome/browser/chromeos/ui/idle_app_name_notification_view.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/test_extension_system.h" | 10 #include "chrome/browser/extensions/test_extension_system.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
| 13 #include "chrome/test/base/browser_with_test_window_test.h" | 13 #include "chrome/test/base/browser_with_test_window_test.h" |
| 14 #include "extensions/common/manifest_constants.h" | 14 #include "extensions/common/manifest_constants.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 const char kTestAppName[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | 18 const char kTestAppName[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 class IdleAppNameNotificationViewTest : public BrowserWithTestWindowTest { | 21 class IdleAppNameNotificationViewTest : public BrowserWithTestWindowTest { |
| 22 public: | 22 public: |
| 23 IdleAppNameNotificationViewTest() | 23 IdleAppNameNotificationViewTest() |
| 24 : BrowserWithTestWindowTest( | 24 : BrowserWithTestWindowTest( |
| 25 Browser::TYPE_TABBED, | 25 Browser::TYPE_TABBED, |
| 26 chrome::HOST_DESKTOP_TYPE_ASH, | 26 chrome::HOST_DESKTOP_TYPE_ASH, |
| 27 false) { | 27 false) { |
| 28 } | 28 } |
| 29 | 29 |
| 30 virtual ~IdleAppNameNotificationViewTest() { | 30 ~IdleAppNameNotificationViewTest() override {} |
| 31 } | |
| 32 | 31 |
| 33 virtual void SetUp() override { | 32 void SetUp() override { |
| 34 // Add the application switch. | 33 // Add the application switch. |
| 35 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 34 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 36 ::switches::kAppId, kTestAppName); | 35 ::switches::kAppId, kTestAppName); |
| 37 | 36 |
| 38 BrowserWithTestWindowTest::SetUp(); | 37 BrowserWithTestWindowTest::SetUp(); |
| 39 | 38 |
| 40 base::DictionaryValue manifest; | 39 base::DictionaryValue manifest; |
| 41 manifest.SetString(extensions::manifest_keys::kName, "Test"); | 40 manifest.SetString(extensions::manifest_keys::kName, "Test"); |
| 42 manifest.SetString(extensions::manifest_keys::kVersion, "1"); | 41 manifest.SetString(extensions::manifest_keys::kVersion, "1"); |
| 43 manifest.SetString(extensions::manifest_keys::kDescription, "Test app"); | 42 manifest.SetString(extensions::manifest_keys::kDescription, "Test app"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 58 | 57 |
| 59 incorrect_extension_ = | 58 incorrect_extension_ = |
| 60 extensions::Extension::Create(base::FilePath(), | 59 extensions::Extension::Create(base::FilePath(), |
| 61 extensions::Manifest::UNPACKED, | 60 extensions::Manifest::UNPACKED, |
| 62 manifest2, | 61 manifest2, |
| 63 extensions::Extension::NO_FLAGS, | 62 extensions::Extension::NO_FLAGS, |
| 64 kTestAppName, | 63 kTestAppName, |
| 65 &error); | 64 &error); |
| 66 } | 65 } |
| 67 | 66 |
| 68 virtual void TearDown() override { | 67 void TearDown() override { |
| 69 // The destruction of the widget might be a delayed task. | 68 // The destruction of the widget might be a delayed task. |
| 70 base::MessageLoop::current()->RunUntilIdle(); | 69 base::MessageLoop::current()->RunUntilIdle(); |
| 71 BrowserWithTestWindowTest::TearDown(); | 70 BrowserWithTestWindowTest::TearDown(); |
| 72 } | 71 } |
| 73 | 72 |
| 74 extensions::Extension* correct_extension() { | 73 extensions::Extension* correct_extension() { |
| 75 return correct_extension_.get(); | 74 return correct_extension_.get(); |
| 76 } | 75 } |
| 77 extensions::Extension* incorrect_extension() { | 76 extensions::Extension* incorrect_extension() { |
| 78 return incorrect_extension_.get(); | 77 return incorrect_extension_.get(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // Check that an invalid app gets shown accordingly. | 122 // Check that an invalid app gets shown accordingly. |
| 124 TEST_F(IdleAppNameNotificationViewTest, CheckInvalidApp) { | 123 TEST_F(IdleAppNameNotificationViewTest, CheckInvalidApp) { |
| 125 // Create a message which is visible for 10ms and fades in/out for 5ms. | 124 // Create a message which is visible for 10ms and fades in/out for 5ms. |
| 126 scoped_ptr<chromeos::IdleAppNameNotificationView> message( | 125 scoped_ptr<chromeos::IdleAppNameNotificationView> message( |
| 127 new chromeos::IdleAppNameNotificationView(10, 5, NULL)); | 126 new chromeos::IdleAppNameNotificationView(10, 5, NULL)); |
| 128 base::string16 text = message->GetShownTextForTest(); | 127 base::string16 text = message->GetShownTextForTest(); |
| 129 base::string16 error = l10n_util::GetStringUTF16( | 128 base::string16 error = l10n_util::GetStringUTF16( |
| 130 IDS_IDLE_APP_NAME_UNKNOWN_APPLICATION_NOTIFICATION); | 129 IDS_IDLE_APP_NAME_UNKNOWN_APPLICATION_NOTIFICATION); |
| 131 EXPECT_EQ(error, text); | 130 EXPECT_EQ(error, text); |
| 132 } | 131 } |
| OLD | NEW |