Commit 68dc0d88 authored by Karandeep Bhatia's avatar Karandeep Bhatia Committed by Commit Bot

Extensions: Annotate RunExtensionTest family of functions with

WARN_UNUSED_RESULT.

The ExtensionApiTest::RunExtensionTest family of functions are used in
extension API tests and they return the success or failure of the test.
However, if the caller does not check the return value, the test is
marked as successful, which can be confusing for developers. This CL
annotates these functions with WARN_UNUSED_RESULT to ensure the return
value is always consumed.

BUG=1135464

Change-Id: Idb6cc6865a0602502a33dd78f55bcf2e28ffd9df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2454406
Commit-Queue: David Bertoni <dbertoni@chromium.org>
Auto-Submit: Karan Bhatia <karandeepb@chromium.org>
Reviewed-by: default avatarDavid Bertoni <dbertoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814855}
parent 11fbb3d4
...@@ -61,18 +61,18 @@ class ExtensionApiTest : public ExtensionBrowserTest { ...@@ -61,18 +61,18 @@ class ExtensionApiTest : public ExtensionBrowserTest {
// Loads |extension_name| and waits for pass / fail notification. // Loads |extension_name| and waits for pass / fail notification.
// |extension_name| is a directory in "chrome/test/data/extensions/api_test". // |extension_name| is a directory in "chrome/test/data/extensions/api_test".
bool RunExtensionTest(const std::string& extension_name); bool RunExtensionTest(const std::string& extension_name) WARN_UNUSED_RESULT;
// Same as RunExtensionTest, except run with the specific |flags| (as defined // Same as RunExtensionTest, except run with the specific |flags| (as defined
// in the Flags enum). // in the Flags enum).
bool RunExtensionTestWithFlags(const std::string& extension_name, bool RunExtensionTestWithFlags(const std::string& extension_name,
int browser_test_flags, int browser_test_flags,
int api_test_flags); int api_test_flags) WARN_UNUSED_RESULT;
// Similar to RunExtensionTest, except sets an additional string argument // Similar to RunExtensionTest, except sets an additional string argument
// |customArg| to the test config object. // |customArg| to the test config object.
bool RunExtensionTestWithArg(const std::string& extension_name, bool RunExtensionTestWithArg(const std::string& extension_name,
const char* custom_arg); const char* custom_arg) WARN_UNUSED_RESULT;
// Similar to RunExtensionTest, except sets an additional string arguments // Similar to RunExtensionTest, except sets an additional string arguments
// |customArg| to the test config object and |flags| (as defined in the Flags // |customArg| to the test config object and |flags| (as defined in the Flags
...@@ -80,31 +80,36 @@ class ExtensionApiTest : public ExtensionBrowserTest { ...@@ -80,31 +80,36 @@ class ExtensionApiTest : public ExtensionBrowserTest {
bool RunExtensionTestWithFlagsAndArg(const std::string& extension_name, bool RunExtensionTestWithFlagsAndArg(const std::string& extension_name,
const char* custom_arg, const char* custom_arg,
int browser_test_flags, int browser_test_flags,
int api_test_flags); int api_test_flags) WARN_UNUSED_RESULT;
// Same as RunExtensionTest, but enables the extension for incognito mode. // Same as RunExtensionTest, but enables the extension for incognito mode.
bool RunExtensionTestIncognito(const std::string& extension_name); bool RunExtensionTestIncognito(const std::string& extension_name)
WARN_UNUSED_RESULT;
// Same as RunExtensionTest, but ignores any warnings in the manifest. // Same as RunExtensionTest, but ignores any warnings in the manifest.
bool RunExtensionTestIgnoreManifestWarnings( bool RunExtensionTestIgnoreManifestWarnings(const std::string& extension_name)
const std::string& extension_name); WARN_UNUSED_RESULT;
// Same as RunExtensionTest, allow old manifest ersions. // Same as RunExtensionTest, allow old manifest ersions.
bool RunExtensionTestAllowOldManifestVersion( bool RunExtensionTestAllowOldManifestVersion(
const std::string& extension_name); const std::string& extension_name) WARN_UNUSED_RESULT;
// Same as RunExtensionTest, but loads extension as component. // Same as RunExtensionTest, but loads extension as component.
bool RunComponentExtensionTest(const std::string& extension_name); bool RunComponentExtensionTest(const std::string& extension_name)
WARN_UNUSED_RESULT;
// Same as RunComponentExtensionTest, but provides extra arg. // Same as RunComponentExtensionTest, but provides extra arg.
bool RunComponentExtensionTestWithArg(const std::string& extension_name, bool RunComponentExtensionTestWithArg(const std::string& extension_name,
const char* custom_arg); const char* custom_arg)
WARN_UNUSED_RESULT;
// Same as RunExtensionTest, but disables file access. // Same as RunExtensionTest, but disables file access.
bool RunExtensionTestNoFileAccess(const std::string& extension_name); bool RunExtensionTestNoFileAccess(const std::string& extension_name)
WARN_UNUSED_RESULT;
// Same as RunExtensionTestIncognito, but disables file access. // Same as RunExtensionTestIncognito, but disables file access.
bool RunExtensionTestIncognitoNoFileAccess(const std::string& extension_name); bool RunExtensionTestIncognitoNoFileAccess(const std::string& extension_name)
WARN_UNUSED_RESULT;
// If not empty, Load |extension_name|, load |page_url| and wait for pass / // If not empty, Load |extension_name|, load |page_url| and wait for pass /
// fail notification from the extension API on the page. Note that if // fail notification from the extension API on the page. Note that if
...@@ -112,56 +117,57 @@ class ExtensionApiTest : public ExtensionBrowserTest { ...@@ -112,56 +117,57 @@ class ExtensionApiTest : public ExtensionBrowserTest {
// the extension. |extension_name| is a directory in // the extension. |extension_name| is a directory in
// "test/data/extensions/api_test". // "test/data/extensions/api_test".
bool RunExtensionSubtest(const std::string& extension_name, bool RunExtensionSubtest(const std::string& extension_name,
const std::string& page_url); const std::string& page_url) WARN_UNUSED_RESULT;
// Same as RunExtensionSubtest, except run with the specific |flags| // Same as RunExtensionSubtest, except run with the specific |flags|
// (as defined in the Flags enum). // (as defined in the Flags enum).
bool RunExtensionSubtest(const std::string& extension_name, bool RunExtensionSubtest(const std::string& extension_name,
const std::string& page_url, const std::string& page_url,
int browser_test_flags, int browser_test_flags,
int api_test_flags); int api_test_flags) WARN_UNUSED_RESULT;
// As above but with support for injecting a custom argument into the test // As above but with support for injecting a custom argument into the test
// config. // config.
bool RunExtensionSubtestWithArg(const std::string& extension_name, bool RunExtensionSubtestWithArg(const std::string& extension_name,
const std::string& page_url, const std::string& page_url,
const char* custom_arg); const char* custom_arg) WARN_UNUSED_RESULT;
// As above but with support for custom flags defined in Flags above. // As above but with support for custom flags defined in Flags above.
bool RunExtensionSubtestWithArgAndFlags(const std::string& extension_name, bool RunExtensionSubtestWithArgAndFlags(const std::string& extension_name,
const std::string& page_url, const std::string& page_url,
const char* custom_arg, const char* custom_arg,
int browser_test_flags, int browser_test_flags,
int api_test_flags); int api_test_flags)
WARN_UNUSED_RESULT;
// Load |page_url| and wait for pass / fail notification from the extension // Load |page_url| and wait for pass / fail notification from the extension
// API on the page. // API on the page.
bool RunPageTest(const std::string& page_url); bool RunPageTest(const std::string& page_url) WARN_UNUSED_RESULT;
bool RunPageTest(const std::string& page_url, bool RunPageTest(const std::string& page_url,
int browser_test_flags, int browser_test_flags,
int api_test_flags); int api_test_flags) WARN_UNUSED_RESULT;
// Similar to RunExtensionTest, except used for running tests in platform app // Similar to RunExtensionTest, except used for running tests in platform app
// shell windows. // shell windows.
bool RunPlatformAppTest(const std::string& extension_name); bool RunPlatformAppTest(const std::string& extension_name) WARN_UNUSED_RESULT;
// Similar to RunPlatformAppTest, except sets an additional string argument // Similar to RunPlatformAppTest, except sets an additional string argument
// |customArg| to the test config object. // |customArg| to the test config object.
bool RunPlatformAppTestWithArg(const std::string& extension_name, bool RunPlatformAppTestWithArg(const std::string& extension_name,
const char* custom_arg); const char* custom_arg) WARN_UNUSED_RESULT;
// Similar to RunPlatformAppTest, with custom |flags| (as defined in the Flags // Similar to RunPlatformAppTest, with custom |flags| (as defined in the Flags
// enum). The kFlagLaunchPlatformApp flag is automatically added. // enum). The kFlagLaunchPlatformApp flag is automatically added.
bool RunPlatformAppTestWithFlags(const std::string& extension_name, bool RunPlatformAppTestWithFlags(const std::string& extension_name,
int browser_test_flags, int browser_test_flags,
int api_test_flags); int api_test_flags) WARN_UNUSED_RESULT;
// Similar to RunPlatformAppTestWithFlags above, except it has an additional // Similar to RunPlatformAppTestWithFlags above, except it has an additional
// string argument |customArg| to the test config object. // string argument |customArg| to the test config object.
bool RunPlatformAppTestWithFlags(const std::string& extension_name, bool RunPlatformAppTestWithFlags(const std::string& extension_name,
const char* custom_arg, const char* custom_arg,
int browser_test_flags, int browser_test_flags,
int api_test_flags); int api_test_flags) WARN_UNUSED_RESULT;
// Start the test server, and store details of its state. Those details // Start the test server, and store details of its state. Those details
// will be available to JavaScript tests using chrome.test.getConfig(). // will be available to JavaScript tests using chrome.test.getConfig().
...@@ -221,7 +227,7 @@ class ExtensionApiTest : public ExtensionBrowserTest { ...@@ -221,7 +227,7 @@ class ExtensionApiTest : public ExtensionBrowserTest {
const std::string& test_page, const std::string& test_page,
const char* custom_arg, const char* custom_arg,
int browser_test_flags, int browser_test_flags,
int api_test_flags); int api_test_flags) WARN_UNUSED_RESULT;
// Hold details of the test, set in C++, which can be accessed by // Hold details of the test, set in C++, which can be accessed by
// javascript using chrome.test.getConfig(). // javascript using chrome.test.getConfig().
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment