Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
| 11 | 11 |
| 12 namespace chromeos { | 12 namespace chromeos { |
| 13 | 13 |
| 14 class ExtensionNetworkingPrivateApiTest : public ExtensionApiTest { | 14 class ExtensionNetworkingPrivateApiTest : public ExtensionApiTest { |
| 15 public: | 15 public: |
| 16 // Whitelist the extension ID of the test extension. | 16 // Whitelist the extension ID of the test extension. |
| 17 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 17 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 18 ExtensionApiTest::SetUpCommandLine(command_line); | 18 ExtensionApiTest::SetUpCommandLine(command_line); |
| 19 command_line->AppendSwitchASCII( | 19 command_line->AppendSwitchASCII( |
| 20 switches::kWhitelistedExtensionID, "epcifkihnkjgphfkloaaleeakhpmgdmn"); | 20 switches::kWhitelistedExtensionID, "epcifkihnkjgphfkloaaleeakhpmgdmn"); |
| 21 } | 21 } |
| 22 | |
| 23 void RunNetworkingSubtest(const std::string& subtest) { | |
| 24 // Make the first character lowercase so we can match naming conventions. | |
| 25 std::string js_named_subtest = subtest; | |
| 26 js_named_subtest[0] = ::tolower(subtest[0]); | |
| 27 EXPECT_TRUE(RunExtensionSubtest( | |
| 28 "networking", "main.html#" + js_named_subtest, | |
| 29 kFlagEnableFileAccess | kFlagLoadAsComponent)) << message_; | |
| 30 } | |
| 22 }; | 31 }; |
| 23 | 32 |
| 24 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, BasicFunctions) { | 33 |
| 25 ASSERT_TRUE(RunComponentExtensionTest("networking")) << message_; | 34 // Place each subtest into a separate browser test so that the stub networking |
| 26 } | 35 // library state is reset for each subtest run. This way they won't affect each |
| 36 // other. | |
| 37 #define DO_NETWORKING_SUBTEST(name) \ | |
| 38 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, name) { \ | |
| 39 RunNetworkingSubtest(#name); \ | |
| 40 } | |
| 41 | |
| 42 DO_NETWORKING_SUBTEST(StartConnect); | |
| 43 DO_NETWORKING_SUBTEST(StartDisconnect); | |
| 44 DO_NETWORKING_SUBTEST(StartConnectNonexistent); | |
| 45 DO_NETWORKING_SUBTEST(GetVisibleNetworks); | |
| 46 DO_NETWORKING_SUBTEST(GetVisibleNetworksWifi); | |
| 47 DO_NETWORKING_SUBTEST(GetProperties); | |
| 48 DO_NETWORKING_SUBTEST(OnNetworksChangedEvent); | |
| 49 DO_NETWORKING_SUBTEST(OnNetworkListChangedEvent); | |
|
not at google - send to devlin
2013/02/12 22:07:25
Another problem with macros is that this makes the
Greg Spencer (Chromium)
2013/02/12 23:11:02
OK, seems consensus is against me here, and the po
| |
| 50 | |
| 51 #undef DO_NETWORKING_SUBTEST | |
|
not at google - send to devlin
2013/02/12 22:07:25
kind of unnecessary since the #define is only per-
| |
| 27 | 52 |
| 28 } // namespace chromeos | 53 } // namespace chromeos |
| OLD | NEW |