Index: chrome/browser/chromeos/login/demo_mode/demo_app_launcher_browsertest.cc |
diff --git a/chrome/browser/chromeos/login/demo_mode/demo_app_launcher_browsertest.cc b/chrome/browser/chromeos/login/demo_mode/demo_app_launcher_browsertest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5b949c4e638db60c89c99fa74444f0fb1e6e4802 |
--- /dev/null |
+++ b/chrome/browser/chromeos/login/demo_mode/demo_app_launcher_browsertest.cc |
@@ -0,0 +1,66 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "apps/app_window_registry.h" |
xiyuan
2014/03/20 04:59:54
seems not used.
rkc
2014/03/20 21:45:01
Done.
|
+#include "base/command_line.h" |
+#include "base/files/file_path.h" |
+#include "base/path_service.h" |
+#include "chrome/browser/apps/app_browsertest_util.h" |
xiyuan
2014/03/20 04:59:54
is this needed?
rkc
2014/03/20 21:45:01
Done.
|
+#include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" |
+#include "chrome/browser/extensions/extension_test_message_listener.h" |
+#include "chrome/browser/profiles/profile_manager.h" |
xiyuan
2014/03/20 04:59:54
no longer needed.
rkc
2014/03/20 21:45:01
Done.
|
+#include "chrome/common/chrome_paths.h" |
+#include "chromeos/chromeos_switches.h" |
+#include "content/public/test/test_utils.h" |
bartfab (slow)
2014/03/20 13:22:29
Nit: Is this used?
rkc
2014/03/20 21:45:01
Done.
|
+#include "extensions/common/extension.h" |
xiyuan
2014/03/20 04:59:54
seems not used.
rkc
2014/03/20 21:45:01
Done.
|
+ |
+ |
xiyuan
2014/03/20 01:14:03
nit: nuke one empty line
rkc
2014/03/20 21:45:01
Done.
|
+namespace chromeos { |
+ |
+char kDemoAppId[] = "klimoghijjogocdbaikffefjfcfheiel"; |
xiyuan
2014/03/20 04:59:54
not used.
rkc
2014/03/20 21:45:01
Done.
|
+ |
+class DemoAppLauncherTest : public InProcessBrowserTest { |
xiyuan
2014/03/20 04:59:54
Let's still derive from ExtensionBrowserTest to be
bartfab (slow)
2014/03/20 13:22:29
Nit: #include "chrome/test/base/in_process_browser
rkc
2014/03/20 21:45:01
Done.
rkc
2014/03/20 21:45:01
Deriving from ExtensionBrowserTest now, so not rel
|
+ public: |
+ DemoAppLauncherTest() { |
+ set_exit_when_last_browser_closes(false); |
+ } |
+ virtual ~DemoAppLauncherTest() {} |
bartfab (slow)
2014/03/20 13:22:29
Nit: add blank line above.
rkc
2014/03/20 21:45:01
Done.
|
+ |
+ virtual void SetUpCommandLine(CommandLine* cmd_line) OVERRIDE { |
bartfab (slow)
2014/03/20 13:22:29
Nit 1: Avoid abbreviations: s/cmd_line/command_lin
rkc
2014/03/20 21:45:01
Done.
|
+ cmd_line->AppendSwitch(chromeos::switches::kLoginManager); |
bartfab (slow)
2014/03/20 13:22:29
Nit: Here and below: No need for the chromeos:: pr
rkc
2014/03/20 21:45:01
Done.
|
+ cmd_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); |
+ cmd_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); |
+ |
+ cmd_line->AppendSwitchASCII(chromeos::switches::kDerelictIdleTimeout, "0"); |
+ cmd_line->AppendSwitchASCII(chromeos::switches::kOobeTimerInterval, "0"); |
+ cmd_line->AppendSwitchASCII(chromeos::switches::kDerelictDetectionTimeout, |
+ "0"); |
+ } |
+ |
+ virtual void SetUp() OVERRIDE { |
+ chromeos::DemoAppLauncher::SetDemoAppPathForTesting(GetTestDemoAppPath()); |
+ InProcessBrowserTest::SetUp(); |
+ } |
+ |
+ base::FilePath GetTestDemoAppPath() { |
bartfab (slow)
2014/03/20 13:22:29
Why is GetTestDemoAppPath() a separate method? The
bartfab (slow)
2014/03/20 13:22:29
Nit: This should be a const method.
rkc
2014/03/20 21:45:01
Done.
rkc
2014/03/20 21:45:01
Getting the path to the test demo app is an indivi
|
+ base::FilePath test_data_dir; |
+ PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
bartfab (slow)
2014/03/20 13:22:29
Nit: PathService::Get() is normally wrapped in an
rkc
2014/03/20 21:45:01
ASSERT and FAIL have issues with returning a FileP
xiyuan
2014/03/20 21:59:44
We can also CHECK. Some tests do that when the enc
bartfab (slow)
2014/03/21 10:37:32
I think CHECKs in tests are a bad idea. They crash
|
+ return test_data_dir.Append(FILE_PATH_LITERAL("chromeos/demo_app")); |
+ } |
+ |
+ void VerifyDemoAppLaunch() { |
+ ExtensionTestMessageListener |
bartfab (slow)
2014/03/20 13:22:29
Nit: You can do this with a temporary:
EXPECT_TRU
rkc
2014/03/20 21:45:01
Done.
|
+ launch_data_check_listener("launchedDemoApp", false); |
+ EXPECT_TRUE(launch_data_check_listener.WaitUntilSatisfied()); |
bartfab (slow)
2014/03/20 13:22:29
1: Overall, this is racy. What if the app manages
rkc
2014/03/20 21:45:01
1.) We don't actually run the message loop until w
bartfab (slow)
2014/03/21 10:37:32
1.) InProcessBrowserTest spins the loop before we
xiyuan
2014/03/21 16:38:16
How about we make it a member of DemoAppLauncherTe
rkc
2014/03/21 23:31:18
Xiyuan and I discussed this offline. This test is
|
+} |
xiyuan
2014/03/20 01:14:03
nit: wrong indent
rkc
2014/03/20 21:45:01
Done.
|
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(DemoAppLauncherTest); |
bartfab (slow)
2014/03/20 13:22:29
Nit: #include "base/basictypes.h"
rkc
2014/03/20 21:45:01
Done.
|
+}; |
+ |
+IN_PROC_BROWSER_TEST_F(DemoAppLauncherTest, Basic) { |
+ VerifyDemoAppLaunch(); |
bartfab (slow)
2014/03/20 13:22:29
Nit: Move the body of your test into here. No need
rkc
2014/03/20 21:45:01
I prefer this in a separate method. This will pote
bartfab (slow)
2014/03/21 10:37:32
The problem is that the EXPECT* and ASSERT* macros
rkc
2014/03/21 23:31:18
Changed this to have the EXPECT_ in the main test
|
+} |
+ |
+} // namespace chromeos |